Name 'flight_Num'必须匹配模式' [a-z][a-zA-Z0-9]*$'

时间:2022-03-15 16:47:39

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;
  }

2 个解决方案

#1


1  

Name 'flight_Num' must match pattern '^[a-z][a-zA-Z0-9]*$'

Name 'flight_Num'必须匹配模式' [a-z][a-zA-Z0-9]*$'

means that the _ character in flight_Num is not allowed.

表示不允许flight_Num中的_字符。

#2


1  

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.

您可以查看各种样式指南,参数名称通常是camel- casepe,如图所示。

http://www.cwu.edu/~gellenbe/javastyle/parameter.html

http://www.cwu.edu/ gellenbe / javastyle / parameter.html

#1


1  

Name 'flight_Num' must match pattern '^[a-z][a-zA-Z0-9]*$'

Name 'flight_Num'必须匹配模式' [a-z][a-zA-Z0-9]*$'

means that the _ character in flight_Num is not allowed.

表示不允许flight_Num中的_字符。

#2


1  

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.

您可以查看各种样式指南,参数名称通常是camel- casepe,如图所示。

http://www.cwu.edu/~gellenbe/javastyle/parameter.html

http://www.cwu.edu/ gellenbe / javastyle / parameter.html