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

时间:2012-11-01 17:32:54

标签: javadoc

当我在程序中运行checkstyle时,我一直收到此错误:

    NonRefundable.java:20:28: Name 'flight_Num' must match pattern '^[a-z][a-zA-Z0-9]*$'.

我不确定我需要做些什么来纠正这个问题。以下是对此特定错误的评论:

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

3 个答案:

答案 0 :(得分:1)

  

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

表示不允许在flight_Num中使用_字符。

答案 1 :(得分:1)

您可能希望查看checkstyle文档,我希望您在修复第一个问题时会看到这一点,但从参数名称中删除下划线。

NonRefundable(String flightNum, Itinerary tripData, double baseFare,
        double fareAdjustmentFactor, double discountFactor)

http://checkstyle.sourceforge.net/config_naming.html

您可以查看各种样式指南,参数名称往往是驼峰式的,如下图所示。

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

答案 2 :(得分:0)

Since Checkstyle 3.0

如果无法删除下划线,则可以使用以下方法来取消此标记:

// SUPPRESS CHECKSTYLE ParameterName
NonRefundable(...)

Related question