java 名称 'flight_Num' 必须匹配模式 '^[az][a-zA-Z0-9]*$'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13182460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Name 'flight_Num' must match pattern '^[a-z][a-zA-Z0-9]*$'
提问by Evan F
I keep getting this error when I run checkstyle on my program:
在我的程序上运行 checkstyle 时,我不断收到此错误:
NonRefundable.java:20:28: Name 'flight_Num' must match pattern '^[a-z][a-zA-Z0-9]*$'.
I'm not sure what I need to do to correct this. Here are the comments for this particular error:
我不确定我需要做什么来纠正这个问题。以下是针对此特定错误的评论:
/** Comments.
*
* @param flight_Num the flight number.
* @param trip_Data the information stored in the Itinerary object.
* @param base_Fare the double representing the initial cost of the trip.
* @param fare_AdjustmentFactor the number factored into the baseFare and
discountFactor used to calculate totalFare.
* @param discount_Factor the number factored into baseFare and
* fare_AdjustmentFactor to calculate totalFare.
*/
NonRefundable(String flight_Num, Itinerary trip_Data, double base_Fare,
double fare_AdjustmentFactor, double discount_Factor) {
super(flight_Num, trip_Data, base_Fare, fare_AdjustmentFactor);
this.discountFactor = discount_Factor;
}
回答by Chuidiang
Name 'flight_Num' must match pattern '^[a-z][a-zA-Z0-9]*$'
名称 'flight_Num' 必须匹配模式 '^[az][a-zA-Z0-9]*$'
means that the _ character in flight_Num is not allowed.
表示不允许使用 flight_Num 中的 _ 字符。
回答by James Black
You may want to look at the checkstyle documentation, and I expect you will see this when you fix the first problem, but remove the underscore from the parameter names.
您可能想查看 checkstyle 文档,我希望您在解决第一个问题时会看到这一点,但从参数名称中删除下划线。
NonRefundable(String flightNum, Itinerary tripData, double baseFare,
double fareAdjustmentFactor, double discountFactor)
http://checkstyle.sourceforge.net/config_naming.html
http://checkstyle.sourceforge.net/config_naming.html
You can look at various style guides and the parameter name tends to be camel-cased, as shown in this particular one.
您可以查看各种样式指南,参数名称往往是驼峰式的,如这个特定的指南所示。
回答by pirho
If it is not possible to remove the underscore it is possible to suppress this with:
如果无法删除下划线,则可以使用以下方法来抑制它:
// SUPPRESS CHECKSTYLE ParameterName
NonRefundable(...)