diff --git a/.travis.yml b/.travis.yml index 14fd16b3..ca9b8e31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,3 +34,5 @@ matrix: - haxelib install compiletime 2.6.0 - haxelib install hxargs 3.0.2 - sed -i 's/:3.3.0//' buildGlobal.hxml + allow_failures: + - haxe: development \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a52bd821..bd6a8b62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +# Version History + ## dev branch / next version (2.x.x) - Fixed enum abstract detection in MagixNumber check, fixes [#104](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/104) ([#449](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/449)) @@ -10,6 +12,7 @@ - Fixed indentation of arrow [#459](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/459) - Fixed position change of semicolon [#460](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/460) - Changed return block indentation [#453](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/453) +- Changed to use formatter [#461](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/461) ## version 2.4.2 (2018-07-01) diff --git a/checkstyle.json b/checkstyle.json index 13154558..1be192d9 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -76,7 +76,8 @@ "props": { "max": 1, "requireEmptyLineAfterAbstract": false, - "requireEmptyLineAfterClass": false + "requireEmptyLineAfterClass": false, + "requireEmptyLineAfterInterface": false }, "type": "EmptyLines" }, @@ -99,16 +100,18 @@ "afterClassStaticVars", "afterClassVars", "betweenClassMethods", - "beginInterface" + "beforeMultiLineComment" ], "upto": [ "betweenImports", "anywhereInFile", "betweenAbstractVars", "beginClass", + "beginInterface", "betweenClassStaticVars", "betweenClassVars", - "betweenInterfaceFields" + "betweenInterfaceFields", + "beforeSingleLineComment" ] }, "type": "ExtendedEmptyLines" @@ -624,11 +627,15 @@ "checkstyle/checks/metrics/CyclomaticComplexityCheck" ], "MethodLength": [ + "checkstyle/checks/metrics/CyclomaticComplexityCheck", "checkstyle/checks/whitespace/WhitespaceAfterCheck", "checkstyle/checks/whitespace/WhitespaceAroundCheck", "checkstyle/checks/whitespace/EmptyLinesCheck", "checkstyle/checks/whitespace/IndentationCheck", - "checkstyle/token/walk/WalkStatement" + "checkstyle/token/walk/WalkStatement", + "checkstyle/utils/ExprUtils", + "checkstyle/utils/ComplexTypeUtils", + "checkstyle/Main" ], "NestedForDepth": [ "TestMain" diff --git a/hxformat.json b/hxformat.json new file mode 100644 index 00000000..9e709b4f --- /dev/null +++ b/hxformat.json @@ -0,0 +1,45 @@ +{ + "sameLine": { + "caseBody": "next", + "tryCatch": "next", + "ifBody": "same", + "ifElse": "next", + "elseBody": "same", + "forBody": "same", + "whileBody": "same", + "comprehensionFor": "same" + }, + "emptyLines": { + "finalNewline": false, + "interfaceEmptyLines": { + "beginType": 1 + } + }, + "wrapping": { + "arrayWrap": { + "rules": [ + { + "conditions": [{"cond": "totalItemLength <= n", "value": 80}], + "type": "noWrap" + }, + { + "conditions": [{"cond": "itemCount >= n", "value": 10}], + "type": "onePerLine" + }, + { + "conditions": [{"cond": "anyItemLength >= n", "value": 30}], + "type": "onePerLine" + }, + { + "conditions": [{"cond": "itemCount >= n", "value": 4}], + "type": "onePerLine" + } + ] + } + }, + "whitespace": { + "arrowFunctionsPolicy": "around", + "functionTypeHaxe3Policy": "around", + "functionTypeHaxe4Policy": "around" + } +} \ No newline at end of file diff --git a/resources/checkstyle-schema.json b/resources/checkstyle-schema.json index 34ef47ef..4a8ba625 100644 --- a/resources/checkstyle-schema.json +++ b/resources/checkstyle-schema.json @@ -17,7 +17,7 @@ "lowerCase" ], "type": "string", - "description": "policy for hexadecimal literals\n\t - upperCase = use uppercase for all letters\n\t - lowerCase = use lowercase for all letters", + "description": "policy for hexadecimal literals\n\t\t- upperCase = use uppercase for all letters\n\t\t- lowerCase = use lowercase for all letters", "propertyOrder": 0 }, "severity": { @@ -28,7 +28,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -60,7 +60,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -97,7 +97,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -129,7 +129,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -174,7 +174,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -221,7 +221,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -311,7 +311,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 7 } }, @@ -353,7 +353,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -385,7 +385,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -417,7 +417,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -485,7 +485,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 5 }, "conditionalPolicy": { @@ -536,7 +536,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -585,7 +585,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -644,7 +644,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -691,7 +691,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -736,7 +736,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -795,7 +795,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -828,7 +828,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -877,7 +877,7 @@ "stmt" ], "type": "string", - "description": "for all empty blocks matched by tokens\n\t - empty = allow empty blocks but enforce \"{}\" notation\n\t - text = must contain something apart from whitespace (comment or statement)\n\t - stmt = must contain at least one statement (that is not a comment)", + "description": "for all empty blocks matched by tokens\n\t\t- empty = allow empty blocks but enforce \"{}\" notation\n\t\t- text = must contain something apart from whitespace (comment or statement)\n\t\t- stmt = must contain at least one statement (that is not a comment)", "propertyOrder": 1 }, "severity": { @@ -888,7 +888,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -930,7 +930,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -972,7 +972,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -1026,7 +1026,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -1063,7 +1063,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -1124,7 +1124,7 @@ "nlow" ], "type": "string", - "description": "placement of left curly\n\t\t- eol = should occur at end of line\n\t - nl = should occur on a new line\n\t\t- nlow = should occur at end of line unless in wrapped code, then it should occur on a new line", + "description": "placement of left curly\n\t\t- eol = should occur at end of line\n\t\t- nl = should occur on a new line\n\t\t- nlow = should occur at end of line unless in wrapped code, then it should occur on a new line", "propertyOrder": 1 }, "severity": { @@ -1135,7 +1135,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -1172,7 +1172,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -1212,7 +1212,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -1262,7 +1262,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -1308,7 +1308,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -1340,7 +1340,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -1387,7 +1387,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -1428,7 +1428,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -1578,7 +1578,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 10 } }, @@ -1639,7 +1639,9 @@ "endTypedef", "betweenTypedefFields", "afterSingleLineComment", - "afterMultiLineComment" + "afterMultiLineComment", + "beforeSingleLineComment", + "beforeMultiLineComment" ], "type": "string", "description": "empty line check supports the following places\n\t- afterAbstractVars = after abstract var block\n\t- afterClassStaticVars = after static class var block\n\t- afterClassVars = after class var block\n\t- afterImports = after all imports/usings\n\t- afterLeftCurly = after left curly\n\t- afterMultiLineComment = after multi line comment\n\t- afterPackage = after package\n\t- afterSingleLineComment = after single line comment\n\t- anywhereInFile = anywhere in file\n\t- beforePackage = before package\n\t- beforeRightCurly = before right curly\n\t- beforeUsing = before using block\n\t- beginAbstract = after abstract left curly\n\t- beginClass = after class left curly\n\t- beginEnum = after enum left curly\n\t- beforeFileEnd = before EOF\n\t- beginInterface = after interface left curly\n\t- beginTypedef = after typedef left curly\n\t- betweenAbstractMethods = between abstract methods\n\t- betweenAbstractVars = between abstract vars\n\t- betweenClassMethods = between class methods\n\t- betweenClassStaticVars = between static class vars\n\t- betweenClassVars = between class vars\n\t- betweenEnumFields = between enum fields\n\t- betweenImports = between imports/usings\n\t- betweenInterfaceFields = between interface fields\n\t- betweenTypedefFields = between typedef fields\n\t- betweenTypes = betgween two types\n\t- endClass = before class right curly\n\t- endAbstract = before abstract right curly\n\t- endInterface = before interface right curly\n\t- endEnum = before enum right curly\n\t- endTypedef = before typedef right curly\n\t- inFunction = anywhere inside function body\n\t- typeDefinition = between type and left curly" @@ -1685,7 +1687,9 @@ "endTypedef", "betweenTypedefFields", "afterSingleLineComment", - "afterMultiLineComment" + "afterMultiLineComment", + "beforeSingleLineComment", + "beforeMultiLineComment" ], "type": "string", "description": "empty line check supports the following places\n\t- afterAbstractVars = after abstract var block\n\t- afterClassStaticVars = after static class var block\n\t- afterClassVars = after class var block\n\t- afterImports = after all imports/usings\n\t- afterLeftCurly = after left curly\n\t- afterMultiLineComment = after multi line comment\n\t- afterPackage = after package\n\t- afterSingleLineComment = after single line comment\n\t- anywhereInFile = anywhere in file\n\t- beforePackage = before package\n\t- beforeRightCurly = before right curly\n\t- beforeUsing = before using block\n\t- beginAbstract = after abstract left curly\n\t- beginClass = after class left curly\n\t- beginEnum = after enum left curly\n\t- beforeFileEnd = before EOF\n\t- beginInterface = after interface left curly\n\t- beginTypedef = after typedef left curly\n\t- betweenAbstractMethods = between abstract methods\n\t- betweenAbstractVars = between abstract vars\n\t- betweenClassMethods = between class methods\n\t- betweenClassStaticVars = between static class vars\n\t- betweenClassVars = between class vars\n\t- betweenEnumFields = between enum fields\n\t- betweenImports = between imports/usings\n\t- betweenInterfaceFields = between interface fields\n\t- betweenTypedefFields = between typedef fields\n\t- betweenTypes = betgween two types\n\t- endClass = before class right curly\n\t- endAbstract = before abstract right curly\n\t- endInterface = before interface right curly\n\t- endEnum = before enum right curly\n\t- endTypedef = before typedef right curly\n\t- inFunction = anywhere inside function body\n\t- typeDefinition = between type and left curly" @@ -1743,7 +1747,9 @@ "endTypedef", "betweenTypedefFields", "afterSingleLineComment", - "afterMultiLineComment" + "afterMultiLineComment", + "beforeSingleLineComment", + "beforeMultiLineComment" ], "type": "string", "description": "empty line check supports the following places\n\t- afterAbstractVars = after abstract var block\n\t- afterClassStaticVars = after static class var block\n\t- afterClassVars = after class var block\n\t- afterImports = after all imports/usings\n\t- afterLeftCurly = after left curly\n\t- afterMultiLineComment = after multi line comment\n\t- afterPackage = after package\n\t- afterSingleLineComment = after single line comment\n\t- anywhereInFile = anywhere in file\n\t- beforePackage = before package\n\t- beforeRightCurly = before right curly\n\t- beforeUsing = before using block\n\t- beginAbstract = after abstract left curly\n\t- beginClass = after class left curly\n\t- beginEnum = after enum left curly\n\t- beforeFileEnd = before EOF\n\t- beginInterface = after interface left curly\n\t- beginTypedef = after typedef left curly\n\t- betweenAbstractMethods = between abstract methods\n\t- betweenAbstractVars = between abstract vars\n\t- betweenClassMethods = between class methods\n\t- betweenClassStaticVars = between static class vars\n\t- betweenClassVars = between class vars\n\t- betweenEnumFields = between enum fields\n\t- betweenImports = between imports/usings\n\t- betweenInterfaceFields = between interface fields\n\t- betweenTypedefFields = between typedef fields\n\t- betweenTypes = betgween two types\n\t- endClass = before class right curly\n\t- endAbstract = before abstract right curly\n\t- endInterface = before interface right curly\n\t- endEnum = before enum right curly\n\t- endTypedef = before typedef right curly\n\t- inFunction = anywhere inside function body\n\t- typeDefinition = between type and left curly" @@ -1794,7 +1800,9 @@ "endTypedef", "betweenTypedefFields", "afterSingleLineComment", - "afterMultiLineComment" + "afterMultiLineComment", + "beforeSingleLineComment", + "beforeMultiLineComment" ], "type": "string", "description": "empty line check supports the following places\n\t- afterAbstractVars = after abstract var block\n\t- afterClassStaticVars = after static class var block\n\t- afterClassVars = after class var block\n\t- afterImports = after all imports/usings\n\t- afterLeftCurly = after left curly\n\t- afterMultiLineComment = after multi line comment\n\t- afterPackage = after package\n\t- afterSingleLineComment = after single line comment\n\t- anywhereInFile = anywhere in file\n\t- beforePackage = before package\n\t- beforeRightCurly = before right curly\n\t- beforeUsing = before using block\n\t- beginAbstract = after abstract left curly\n\t- beginClass = after class left curly\n\t- beginEnum = after enum left curly\n\t- beforeFileEnd = before EOF\n\t- beginInterface = after interface left curly\n\t- beginTypedef = after typedef left curly\n\t- betweenAbstractMethods = between abstract methods\n\t- betweenAbstractVars = between abstract vars\n\t- betweenClassMethods = between class methods\n\t- betweenClassStaticVars = between static class vars\n\t- betweenClassVars = between class vars\n\t- betweenEnumFields = between enum fields\n\t- betweenImports = between imports/usings\n\t- betweenInterfaceFields = between interface fields\n\t- betweenTypedefFields = between typedef fields\n\t- betweenTypes = betgween two types\n\t- endClass = before class right curly\n\t- endAbstract = before abstract right curly\n\t- endInterface = before interface right curly\n\t- endEnum = before enum right curly\n\t- endTypedef = before typedef right curly\n\t- inFunction = anywhere inside function body\n\t- typeDefinition = between type and left curly" @@ -1840,7 +1848,9 @@ "endTypedef", "betweenTypedefFields", "afterSingleLineComment", - "afterMultiLineComment" + "afterMultiLineComment", + "beforeSingleLineComment", + "beforeMultiLineComment" ], "type": "string", "description": "empty line check supports the following places\n\t- afterAbstractVars = after abstract var block\n\t- afterClassStaticVars = after static class var block\n\t- afterClassVars = after class var block\n\t- afterImports = after all imports/usings\n\t- afterLeftCurly = after left curly\n\t- afterMultiLineComment = after multi line comment\n\t- afterPackage = after package\n\t- afterSingleLineComment = after single line comment\n\t- anywhereInFile = anywhere in file\n\t- beforePackage = before package\n\t- beforeRightCurly = before right curly\n\t- beforeUsing = before using block\n\t- beginAbstract = after abstract left curly\n\t- beginClass = after class left curly\n\t- beginEnum = after enum left curly\n\t- beforeFileEnd = before EOF\n\t- beginInterface = after interface left curly\n\t- beginTypedef = after typedef left curly\n\t- betweenAbstractMethods = between abstract methods\n\t- betweenAbstractVars = between abstract vars\n\t- betweenClassMethods = between class methods\n\t- betweenClassStaticVars = between static class vars\n\t- betweenClassVars = between class vars\n\t- betweenEnumFields = between enum fields\n\t- betweenImports = between imports/usings\n\t- betweenInterfaceFields = between interface fields\n\t- betweenTypedefFields = between typedef fields\n\t- betweenTypes = betgween two types\n\t- endClass = before class right curly\n\t- endAbstract = before abstract right curly\n\t- endInterface = before interface right curly\n\t- endEnum = before enum right curly\n\t- endTypedef = before typedef right curly\n\t- inFunction = anywhere inside function body\n\t- typeDefinition = between type and left curly" @@ -1862,7 +1872,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 8 } }, @@ -2242,7 +2252,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 8 } }, @@ -2274,7 +2284,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -2306,7 +2316,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -2343,7 +2353,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -2380,7 +2390,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -2417,7 +2427,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -2454,7 +2464,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -2509,7 +2519,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -2546,7 +2556,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 }, "ignoreOverriddenMethods": { @@ -2583,7 +2593,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -2615,7 +2625,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -2647,7 +2657,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -2701,7 +2711,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -2743,7 +2753,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -2783,7 +2793,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -2825,7 +2835,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -2893,7 +2903,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -2943,7 +2953,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -2975,7 +2985,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -3022,7 +3032,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -3054,7 +3064,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -3112,7 +3122,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -3144,7 +3154,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -3193,7 +3203,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 }, "maxTotal": { @@ -3230,7 +3240,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -3277,7 +3287,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -3314,7 +3324,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -3351,7 +3361,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -3388,7 +3398,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -3425,7 +3435,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -3462,7 +3472,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -3511,7 +3521,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, @@ -3578,7 +3588,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 7 } }, @@ -3610,7 +3620,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -3659,7 +3669,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -3691,7 +3701,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 0 } }, @@ -3758,7 +3768,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -3805,7 +3815,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 3 } }, @@ -4155,7 +4165,7 @@ "aligned" ], "type": "string", - "description": "indentation of conditional statements\n\t - startOfLine = #if, #else, #elseif and #end must start at beginning of line\n\t - aligned = indentation of #if, #else, #elseif and #end must match surrounding code\n\n\t\tBoth \"aligned\" and \"startOfLine\" will produce a message if conditional compilation flags are not on a separate line.\n\t\tAll #else, #elseif and #end flags must have the same indentation as their corresponding #if.", + "description": "indentation of conditional statements\n\t\t- startOfLine = #if, #else, #elseif and #end must start at beginning of line\n\t\t- aligned = indentation of #if, #else, #elseif and #end must match surrounding code\n\n\t\tBoth \"aligned\" and \"startOfLine\" will produce a message if conditional compilation flags are not on a separate line.\n\t\tAll #else, #elseif and #end flags must have the same indentation as their corresponding #if.", "propertyOrder": 0 }, "allowSingleline": { @@ -4171,7 +4181,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 2 } }, @@ -4211,7 +4221,7 @@ "IGNORE" ], "type": "string", - "description": "sets gravity of reported violations:\n - IGNORE = do not report violations, violations do not appear anywhere in output\n - INFO = all violations have info / lowest priority\n - WARNING = all violations have warning / medium priority\n - ERROR = all violations have error / highest priority", + "description": "sets gravity of reported violations:\n\t- IGNORE = do not report violations, violations do not appear anywhere in output\n\t- INFO = all violations have info / lowest priority\n\t- WARNING = all violations have warning / medium priority\n\t- ERROR = all violations have error / highest priority", "propertyOrder": 1 } }, diff --git a/src/checkstyle/Checker.hx b/src/checkstyle/Checker.hx index 5a6c1f94..7768830b 100644 --- a/src/checkstyle/Checker.hx +++ b/src/checkstyle/Checker.hx @@ -3,14 +3,10 @@ package checkstyle; import haxeparser.HaxeParser; import haxeparser.HaxeLexer; import sys.io.File; - import checkstyle.checks.Check; - import checkstyle.config.ExcludeManager; import checkstyle.config.ExcludeRange; - import checkstyle.reporter.ReporterManager; - import tokentree.TokenTreeBuilder; class Checker { @@ -23,10 +19,11 @@ class Checker { public var checks:Array; public var baseDefines:Array; public var defineCombinations:Array>; - public var linesIdx:Array; public var lineSeparator:String; + var tokenTree:TokenTree; + public var asts:Array; public var excludesRanges:Map>; @@ -56,13 +53,13 @@ class Checker { for (i in 0...code.length) { if (code.get(i) == 0x0A) { - linesIdx.push({l:last, r:i}); + linesIdx.push({l: last, r: i}); last = i + 1; left = false; } left = true; } - if (left) linesIdx.push({l:last, r:code.length}); + if (left) linesIdx.push({l: last, r: code.length}); } public function getLinePos(off:Int):LinePos { @@ -76,7 +73,7 @@ class Checker { var center:Int = lowerBound + Math.floor((upperBound - lowerBound) / 2); var matchLeft:Bool = linesIdx[center].l <= off; var matchRight:Bool = linesIdx[center].r >= off; - if (matchLeft && matchRight) return { line: center, ofs: off - linesIdx[center].l }; + if (matchLeft && matchRight) return {line: center, ofs: off - linesIdx[center].l}; if (matchLeft) { lowerBound = center + 1; continue; @@ -111,7 +108,7 @@ class Checker { return; } } - //default + // default lineSeparator = "\n"; } diff --git a/src/checkstyle/CheckerPool.hx b/src/checkstyle/CheckerPool.hx index ec323b43..9e75d8be 100644 --- a/src/checkstyle/CheckerPool.hx +++ b/src/checkstyle/CheckerPool.hx @@ -1,7 +1,6 @@ package checkstyle; class CheckerPool { - var parserQueue:ParserQueue; var templateChecker:Checker; var threads:Array; diff --git a/src/checkstyle/CheckerThread.hx b/src/checkstyle/CheckerThread.hx index b8e58b5c..6e5759d9 100644 --- a/src/checkstyle/CheckerThread.hx +++ b/src/checkstyle/CheckerThread.hx @@ -9,11 +9,8 @@ import cpp.hl.Thread; #else import checkstyle.utils.Thread; #end - import checkstyle.checks.Check; - import checkstyle.config.ExcludeManager; - import checkstyle.reporter.ReporterManager; class CheckerThread { @@ -38,14 +35,22 @@ class CheckerThread { checks = []; var propsNotAllowed:Array = [ - "moduleName", "type", "categories", - "points", "desc", "currentState", "skipOverStringStart", - "commentStartRE", "commentBlockEndRE", "stringStartRE", - "stringInterpolatedEndRE", "stringLiteralEndRE" + "moduleName", + "type", + "categories", + "points", + "desc", + "currentState", + "skipOverStringStart", + "commentStartRE", + "commentBlockEndRE", + "stringStartRE", + "stringInterpolatedEndRE", + "stringLiteralEndRE" ]; for (check in templateChecks) { - var newCheck = Type.createInstance (Type.getClass(check), []); + var newCheck = Type.createInstance(Type.getClass(check), []); for (prop in Reflect.fields(check)) { if (propsNotAllowed.contains(prop)) continue; diff --git a/src/checkstyle/ChecksInfo.hx b/src/checkstyle/ChecksInfo.hx index e8144fdb..395bc632 100644 --- a/src/checkstyle/ChecksInfo.hx +++ b/src/checkstyle/ChecksInfo.hx @@ -3,7 +3,6 @@ package checkstyle; import checkstyle.checks.Check; class ChecksInfo { - var checkInfos:Map; public function new() { diff --git a/src/checkstyle/Main.hx b/src/checkstyle/Main.hx index b5923a4d..e9977c9e 100644 --- a/src/checkstyle/Main.hx +++ b/src/checkstyle/Main.hx @@ -22,7 +22,6 @@ import sys.io.File; import haxe.io.Path; class Main { - static var DEFAULT_CONFIG:String = "checkstyle.json"; static var DEFAULT_EXCLUDE_CONFIG:String = "checkstyle-exclude.json"; static var REPORT_TYPE:String = "text"; @@ -55,28 +54,44 @@ class Main { function run(args:Array) { var argHandler = Args.generate([ - @doc("Set source path to process (multiple allowed)") ["-s", "--source"] => function(path:String) configParser.paths.push(path), - @doc("Set config file (default: checkstyle.json)") ["-c", "--config"] => function(path:String) configPath = path, - @doc("Set exclude file (default: checkstyle-exclude.json)") ["-e", "--exclude"] => function(path:String) excludePath = path, - @doc("Set reporter (xml, json or text, default: text)") ["-r", "--reporter"] => function(name:String) REPORT_TYPE = name, - @doc("Set reporter output path") ["-p", "--path"] => function(path:String) { + @doc("Set source path to process (multiple allowed)") + ["-s", "--source"] => function(path:String) configParser.paths.push(path), + @doc("Set config file (default: checkstyle.json)") + ["-c", "--config"] => function(path:String) configPath = path, + @doc("Set exclude file (default: checkstyle-exclude.json)") + ["-e", "--exclude"] => function(path:String) excludePath = path, + @doc("Set reporter (xml, json or text, default: text)") + ["-r", "--reporter"] => function(name:String) REPORT_TYPE = name, + @doc("Set reporter output path") + ["-p", "--path"] => function(path:String) { XML_PATH = path; JSON_PATH = path; TEXT_PATH = path; }, - @doc("Set reporter style (XSLT)") ["-x", "--xslt"] => function(style:String) STYLE = style, - @doc("Sets the number of checker threads") ["-checkerthreads"] => function (num:Int) configParser.overrideCheckerThreads = num, - @doc("Generate a default config and exit") ["-default-config", "--default-config"] => function(path) generateDefaultConfig(path), - @doc("Try to detect your coding style (experimental)") ["-detect"] => function (path) detectCodingStyle(path), - @doc("Return number of failed checks in exitcode") ["-exitcode"] => function() EXIT_CODE = true, - @doc("List all available checks and exit") ["-list-checks", "--list-checks"] => function() listChecks(), - @doc("List all available reporters and exit") ["-list-reporters", "--list-reporters"] => function() listReporters(), - @doc("Omit styling in output summary") ["-nostyle"] => function() NO_STYLE = true, - @doc("Do not use checker threads") ["-nothreads"] => function () disableThreads = true, - @doc("Show percentage progress") ["-progress"] => function() SHOW_PROGRESS = true, - @doc("Show checks missing from active config") ["-show-missing-checks"] => function () SHOW_MISSING_CHECKS = true, - @doc("Adds error messages for files that checkstyle fails to parse") ["-show-parser-errors"] => function () - ReporterManager.SHOW_PARSE_ERRORS = true, + @doc("Set reporter style (XSLT)") + ["-x", "--xslt"] => function(style:String) STYLE = style, + @doc("Sets the number of checker threads") + ["-checkerthreads"] => function(num:Int) configParser.overrideCheckerThreads = num, + @doc("Generate a default config and exit") + ["-default-config", "--default-config"] => function(path) generateDefaultConfig(path), + @doc("Try to detect your coding style (experimental)") + ["-detect"] => function(path) detectCodingStyle(path), + @doc("Return number of failed checks in exitcode") + ["-exitcode"] => function() EXIT_CODE = true, + @doc("List all available checks and exit") + ["-list-checks", "--list-checks"] => function() listChecks(), + @doc("List all available reporters and exit") + ["-list-reporters", "--list-reporters"] => function() listReporters(), + @doc("Omit styling in output summary") + ["-nostyle"] => function() NO_STYLE = true, + @doc("Do not use checker threads") + ["-nothreads"] => function() disableThreads = true, + @doc("Show percentage progress") + ["-progress"] => function() SHOW_PROGRESS = true, + @doc("Show checks missing from active config") + ["-show-missing-checks"] => function() SHOW_MISSING_CHECKS = true, + @doc("Adds error messages for files that checkstyle fails to parse") + ["-show-parser-errors"] => function() ReporterManager.SHOW_PARSE_ERRORS = true, _ => function(arg:String) failWith("Unknown command: " + arg) ]); @@ -120,11 +135,17 @@ class Main { var totalChecks = configParser.getCheckCount(); var checksUsed = configParser.getUsedCheckCount(); return switch (REPORT_TYPE) { - case "xml": new XMLReporter(numFiles, totalChecks, checksUsed, XML_PATH, STYLE, NO_STYLE); - case "json": new JSONReporter(numFiles, totalChecks, checksUsed, JSON_PATH, NO_STYLE); - case "text": new TextReporter(numFiles, totalChecks, checksUsed, TEXT_PATH, NO_STYLE); - case "codeclimate": new CodeClimateReporter(numFiles, totalChecks, checksUsed, null, NO_STYLE); - default: failWith('Unknown reporter: $REPORT_TYPE'); null; + case "xml": + new XMLReporter(numFiles, totalChecks, checksUsed, XML_PATH, STYLE, NO_STYLE); + case "json": + new JSONReporter(numFiles, totalChecks, checksUsed, JSON_PATH, NO_STYLE); + case "text": + new TextReporter(numFiles, totalChecks, checksUsed, TEXT_PATH, NO_STYLE); + case "codeclimate": + new CodeClimateReporter(numFiles, totalChecks, checksUsed, null, NO_STYLE); + default: + failWith('Unknown reporter: $REPORT_TYPE'); + null; } } @@ -204,7 +225,9 @@ class Main { files.sortStrings(); var i:Int = 0; - return [for (file in files) { name:file, content:null, index:i++ }]; + return [ + for (file in files) {name: file, content: null, index: i++} + ]; } function traverse(path:String, files:Array) { diff --git a/src/checkstyle/ParserQueue.hx b/src/checkstyle/ParserQueue.hx index c51f1fee..60688495 100644 --- a/src/checkstyle/ParserQueue.hx +++ b/src/checkstyle/ParserQueue.hx @@ -13,7 +13,6 @@ import cpp.hl.Thread; import checkstyle.utils.Mutex; import checkstyle.utils.Thread; #end - class ParserQueue { static inline var SLEEP_TIME:Float = 0.1; @@ -44,7 +43,7 @@ class ParserQueue { Sys.sleep(SLEEP_TIME); continue; } - var file = files.shift (); + var file = files.shift(); var checker:Checker = new Checker(); checker.baseDefines = templateChecker.baseDefines; checker.defineCombinations = templateChecker.defineCombinations; diff --git a/src/checkstyle/SeverityLevel.hx b/src/checkstyle/SeverityLevel.hx index c3657444..72a15a00 100644 --- a/src/checkstyle/SeverityLevel.hx +++ b/src/checkstyle/SeverityLevel.hx @@ -1,12 +1,12 @@ package checkstyle; /** - sets gravity of reported violations: - - IGNORE = do not report violations, violations do not appear anywhere in output - - INFO = all violations have info / lowest priority - - WARNING = all violations have warning / medium priority - - ERROR = all violations have error / highest priority - **/ + sets gravity of reported violations: + - IGNORE = do not report violations, violations do not appear anywhere in output + - INFO = all violations have info / lowest priority + - WARNING = all violations have warning / medium priority + - ERROR = all violations have error / highest priority +**/ @:enum abstract SeverityLevel(String) from String { var INFO = "INFO"; diff --git a/src/checkstyle/checks/Check.hx b/src/checkstyle/checks/Check.hx index 2580c3b8..698316a8 100644 --- a/src/checkstyle/checks/Check.hx +++ b/src/checkstyle/checks/Check.hx @@ -3,7 +3,6 @@ package checkstyle.checks; import checkstyle.config.ExcludeRange; class Check { - public var severity:SeverityLevel; public var type(default, null):CheckType; public var categories:Array; @@ -70,18 +69,18 @@ class Check { public function log(msg:String, startLine:Int, startColumn:Int, endLine:Int, endColumn:Int, ?code:String, ?sev:SeverityLevel) { if (sev == null) sev = severity; messages.push({ - fileName:checker.file.name, - message:msg, - code:code, - desc:desc, - startLine:startLine, - endLine:endLine, - startColumn:startColumn, - endColumn:endColumn, - severity:sev, - moduleName:getModuleName(), - categories:categories, - points:points + fileName: checker.file.name, + message: msg, + code: code, + desc: desc, + startLine: startLine, + endLine: endLine, + startColumn: startColumn, + endColumn: endColumn, + severity: sev, + moduleName: getModuleName(), + categories: categories, + points: points }); } @@ -137,7 +136,7 @@ class Check { function isCharPosExtern(pos:Int):Bool { if (checker.ast.decls == null) return false; for (td in checker.ast.decls) { - switch (td.decl){ + switch (td.decl) { case EAbstract(d): case EClass(d): if ((pos <= td.pos.max) && (pos >= td.pos.min)) return d.flags.contains(HExtern); diff --git a/src/checkstyle/checks/block/ConditionalCompilationCheck.hx b/src/checkstyle/checks/block/ConditionalCompilationCheck.hx index 998ce2d7..f4c16d9a 100644 --- a/src/checkstyle/checks/block/ConditionalCompilationCheck.hx +++ b/src/checkstyle/checks/block/ConditionalCompilationCheck.hx @@ -1,25 +1,24 @@ package checkstyle.checks.block; /** - Checks placement and indentation of conditional compilation flags. - **/ + Checks placement and indentation of conditional compilation flags. +**/ @name("ConditionalCompilation") @desc("Checks placement and indentation of conditional compilation flags.") class ConditionalCompilationCheck extends Check { - /** - indentation of conditional statements - - startOfLine = #if, #else, #elseif and #end must start at beginning of line - - aligned = indentation of #if, #else, #elseif and #end must match surrounding code + indentation of conditional statements + - startOfLine = #if, #else, #elseif and #end must start at beginning of line + - aligned = indentation of #if, #else, #elseif and #end must match surrounding code Both "aligned" and "startOfLine" will produce a message if conditional compilation flags are not on a separate line. All #else, #elseif and #end flags must have the same indentation as their corresponding #if. - **/ + **/ public var policy:ConditionalCompilationPolicy; /** allows or prevents using single line conditional compilation flags. - **/ + **/ public var allowSingleline:Bool; public function new() { @@ -152,25 +151,29 @@ class ConditionalCompilationCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "policy", - values: [START_OF_LINE, ALIGNED] - }, + return [ { - propertyName: "allowSingleline", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "policy", + values: [START_OF_LINE, ALIGNED] + }, + { + propertyName: "allowSingleline", + values: [true, false] + } + ] + } + ]; } } /** - indentation of conditional statements - - startOfLine = #if, #else, #elseif and #end must start at beginning of line - - aligned = indentation of #if, #else, #elseif and #end must match surrounding code - **/ + indentation of conditional statements + - startOfLine = #if, #else, #elseif and #end must start at beginning of line + - aligned = indentation of #if, #else, #elseif and #end must match surrounding code +**/ @:enum abstract ConditionalCompilationPolicy(String) { var START_OF_LINE = "startOfLine"; diff --git a/src/checkstyle/checks/block/EmptyBlockCheck.hx b/src/checkstyle/checks/block/EmptyBlockCheck.hx index e18041e0..f1b823af 100644 --- a/src/checkstyle/checks/block/EmptyBlockCheck.hx +++ b/src/checkstyle/checks/block/EmptyBlockCheck.hx @@ -1,14 +1,13 @@ package checkstyle.checks.block; /** - Checks for empty blocks. The policy to verify is specified using the property "option". - **/ + Checks for empty blocks. The policy to verify is specified using the property "option". +**/ @name("EmptyBlock") @desc("Checks for empty blocks. The policy to verify is specified using the property `option`.") class EmptyBlockCheck extends Check { - /** - matches only blocks specified in tokens list: + matches only blocks specified in tokens list: - CLASS_DEF = class definition "class Test {}" - ENUM_DEF = enum definition "enum Test {}" - ABSTRACT_DEF = abstract definition "abstract Test {}" @@ -23,15 +22,15 @@ class EmptyBlockCheck extends Check { - TRY = try body "try {}" - CATCH = catch body "catch (e:Dynamic) {}" - REIFICATION = macro reification "$i{}" - **/ + **/ public var tokens:Array; /** - for all empty blocks matched by tokens - - empty = allow empty blocks but enforce "{}" notation - - text = must contain something apart from whitespace (comment or statement) - - stmt = must contain at least one statement (that is not a comment) - **/ + for all empty blocks matched by tokens + - empty = allow empty blocks but enforce "{}" notation + - text = must contain something apart from whitespace (comment or statement) + - stmt = must contain at least one statement (that is not a comment) + **/ public var option:EmptyBlockCheckOption; public function new() { @@ -66,10 +65,14 @@ class EmptyBlockCheck extends Check { if (isPosSuppressed(brOpen.pos)) continue; if (filterParentToken(brOpen.parent)) continue; switch (option) { - case TEXT: checkForText(brOpen); - case STATEMENT: checkForStatement(brOpen); - case EMPTY: checkForEmpty(brOpen); - default: checkForText(brOpen); + case TEXT: + checkForText(brOpen); + case STATEMENT: + checkForStatement(brOpen); + case EMPTY: + checkForEmpty(brOpen); + default: + checkForText(brOpen); } } } @@ -77,20 +80,34 @@ class EmptyBlockCheck extends Check { function filterParentToken(token:TokenTree):Bool { if ((token == null) || (token.tok == null)) return false; switch (token.tok) { - case Kwd(KwdClass): return !hasToken(CLASS_DEF); - case Kwd(KwdInterface): return !hasToken(INTERFACE_DEF); - case Kwd(KwdAbstract): return !hasToken(ABSTRACT_DEF); - case Kwd(KwdTypedef): return !hasToken(TYPEDEF_DEF); - case Kwd(KwdEnum): return !hasToken(ENUM_DEF); - case Kwd(KwdFunction): return !hasToken(FUNCTION); - case Kwd(KwdIf), Kwd(KwdElse): return !hasToken(IF); - case Kwd(KwdFor): return !hasToken(FOR); - case Kwd(KwdWhile): return !hasToken(WHILE); - case Kwd(KwdTry): return !hasToken(TRY); - case Kwd(KwdCatch): return !hasToken(CATCH); - case Kwd(KwdSwitch), Kwd(KwdCase), Kwd(KwdDefault): return !hasToken(SWITCH); - case POpen, BkOpen, BrOpen, Kwd(KwdReturn): return !hasToken(OBJECT_DECL); - case Dollar(_): return !hasToken(REIFICATION); + case Kwd(KwdClass): + return !hasToken(CLASS_DEF); + case Kwd(KwdInterface): + return !hasToken(INTERFACE_DEF); + case Kwd(KwdAbstract): + return !hasToken(ABSTRACT_DEF); + case Kwd(KwdTypedef): + return !hasToken(TYPEDEF_DEF); + case Kwd(KwdEnum): + return !hasToken(ENUM_DEF); + case Kwd(KwdFunction): + return !hasToken(FUNCTION); + case Kwd(KwdIf), Kwd(KwdElse): + return !hasToken(IF); + case Kwd(KwdFor): + return !hasToken(FOR); + case Kwd(KwdWhile): + return !hasToken(WHILE); + case Kwd(KwdTry): + return !hasToken(TRY); + case Kwd(KwdCatch): + return !hasToken(CATCH); + case Kwd(KwdSwitch), Kwd(KwdCase), Kwd(KwdDefault): + return !hasToken(SWITCH); + case POpen, BkOpen, BrOpen, Kwd(KwdReturn): + return !hasToken(OBJECT_DECL); + case Dollar(_): + return !hasToken(REIFICATION); case Binop(OpAssign): // could be OBJECT_DECL or TYPEDEF_DEF if ((token.parent != null) && (token.parent.parent != null)) { @@ -111,7 +128,7 @@ class EmptyBlockCheck extends Check { return; } var lastChild:TokenTree = brOpen.getLastChild(); - if ((brOpen.children.length == 2) && lastChild.is(Semicolon)){ + if ((brOpen.children.length == 2) && lastChild.is(Semicolon)) { logPos("Empty block should contain a comment or a statement", brOpen.getPos()); return; } @@ -123,7 +140,7 @@ class EmptyBlockCheck extends Check { return; } var lastChild:TokenTree = brOpen.getLastChild(); - if ((brOpen.children.length == 2) && lastChild.is(Semicolon)){ + if ((brOpen.children.length == 2) && lastChild.is(Semicolon)) { logPos("Empty block should contain a statement", brOpen.getPos()); return; } diff --git a/src/checkstyle/checks/block/LeftCurlyCheck.hx b/src/checkstyle/checks/block/LeftCurlyCheck.hx index 6bec5a25..94d6a8bc 100644 --- a/src/checkstyle/checks/block/LeftCurlyCheck.hx +++ b/src/checkstyle/checks/block/LeftCurlyCheck.hx @@ -1,14 +1,13 @@ package checkstyle.checks.block; /** - Checks for the placement of left curly braces ("{") for code blocks. The policy to verify is specified using the property "option". - **/ + Checks for the placement of left curly braces ("{") for code blocks. The policy to verify is specified using the property "option". +**/ @name("LeftCurly") @desc("Checks for the placement of left curly braces (`{`) for code blocks. The policy to verify is specified using the property `option`.") class LeftCurlyCheck extends Check { - /** - matches only left curlys specified in tokens list: + matches only left curlys specified in tokens list: - CLASS_DEF = class definition "class Test {}" - ENUM_DEF = enum definition "enum Test {}" - ABSTRACT_DEF = abstract definition "abstract Test {}" @@ -24,20 +23,20 @@ class LeftCurlyCheck extends Check { - CATCH = catch body "catch (e:Dynamic) {}" - REIFICATION = macro reification "$i{}" - ARRAY_COMPREHENSION = array comprehension "[for (i in 0...10) {i * 2}]" - **/ + **/ public var tokens:Array; /** - placement of left curly + placement of left curly - eol = should occur at end of line - - nl = should occur on a new line + - nl = should occur on a new line - nlow = should occur at end of line unless in wrapped code, then it should occur on a new line - **/ + **/ public var option:LeftCurlyCheckOption; /** - allow single line blocks - **/ + allow single line blocks + **/ public var ignoreEmptySingleline:Bool; public function new() { @@ -48,7 +47,7 @@ class LeftCurlyCheck extends Check { ABSTRACT_DEF, TYPEDEF_DEF, INTERFACE_DEF, - //OBJECT_DECL, // => allow inline object declarations + // OBJECT_DECL, // => allow inline object declarations FUNCTION, FOR, IF, @@ -85,9 +84,9 @@ class LeftCurlyCheck extends Check { /** find effective parent token and check against configured tokens - **/ + **/ function findParentToken(token:TokenTree):ParentToken { - if ((token == null) || (token.tok == null)) return {token:token, hasToken: false}; + if ((token == null) || (token.tok == null)) return {token: token, hasToken: false}; switch (token.tok) { case Kwd(KwdClass): return {token: token, hasToken: hasToken(CLASS_DEF)}; @@ -138,7 +137,7 @@ class LeftCurlyCheck extends Check { } function findParentTokenDblDot(token:TokenTree):ParentToken { - if ((token == null) || (token.tok == null)) return {token:token, hasToken: false}; + if ((token == null) || (token.tok == null)) return {token: token, hasToken: false}; switch (token.tok) { case Kwd(KwdCase), Kwd(KwdDefault): return {token: token, hasToken: hasToken(SWITCH)}; @@ -148,8 +147,7 @@ class LeftCurlyCheck extends Check { // could be OBJECT_DECL or TYPEDEF_DEF if ((token.parent != null) && (token.parent.parent != null)) { switch (token.parent.parent.tok) { - case Kwd(KwdTypedef): - return {token: token, hasToken: hasToken(TYPEDEF_DEF)}; + case Kwd(KwdTypedef): return {token: token, hasToken: hasToken(TYPEDEF_DEF)}; default: } } @@ -227,48 +225,54 @@ class LeftCurlyCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [{ - propertyName: "tokens", - value: [ - CLASS_DEF, - ENUM_DEF, - ABSTRACT_DEF, - INTERFACE_DEF, - FUNCTION, - FOR, - IF, - WHILE, - SWITCH, - TRY, - CATCH - ] - }], - properties: [{ - propertyName: "option", - values: [EOL, NLOW, NL] - }, + return [ { - propertyName: "ignoreEmptySingleline", - values: [true, false] - }] - }, - { - fixed: [{ - propertyName: "tokens", - value: [ - TYPEDEF_DEF, + fixed: [ + { + propertyName: "tokens", + value: [ + CLASS_DEF, + ENUM_DEF, + ABSTRACT_DEF, + INTERFACE_DEF, + FUNCTION, + FOR, + IF, + WHILE, + SWITCH, + TRY, + CATCH + ] + } + ], + properties: [ + { + propertyName: "option", + values: [EOL, NLOW, NL] + }, + { + propertyName: "ignoreEmptySingleline", + values: [true, false] + } ] - }], - properties: [{ - propertyName: "option", - values: [EOL, NLOW, NL] }, { - propertyName: "ignoreEmptySingleline", - values: [true, false] - }] - }]; + fixed: [{ + propertyName: "tokens", + value: [TYPEDEF_DEF] + }], + properties: [ + { + propertyName: "option", + values: [EOL, NLOW, NL] + }, + { + propertyName: "ignoreEmptySingleline", + values: [true, false] + } + ] + } + ]; } } @@ -284,7 +288,6 @@ abstract LeftCurlyCheckToken(String) { var ABSTRACT_DEF = "ABSTRACT_DEF"; var TYPEDEF_DEF = "TYPEDEF_DEF"; var INTERFACE_DEF = "INTERFACE_DEF"; - var OBJECT_DECL = "OBJECT_DECL"; var FUNCTION = "FUNCTION"; var FOR = "FOR"; diff --git a/src/checkstyle/checks/block/NeedBracesCheck.hx b/src/checkstyle/checks/block/NeedBracesCheck.hx index 1f9c02e2..4300eadd 100644 --- a/src/checkstyle/checks/block/NeedBracesCheck.hx +++ b/src/checkstyle/checks/block/NeedBracesCheck.hx @@ -3,13 +3,12 @@ package checkstyle.checks.block; /** Checks for braces on function, if, for and while statements. It has an option to allow single line statements without braces using property "allowSingleLineStatement" like "if (b) return 10;". - **/ +**/ @name("NeedBraces") @desc("Checks for braces on function, if, for and while statements. It has an option to allow single line statements without braces using property `allowSingleLineStatement` like `if (b) return 10;`.") class NeedBracesCheck extends Check { - /** - matches only statements specified in tokens list: + matches only statements specified in tokens list: - FUNCTION = function body "funnction test () {}" - FOR = for body "for (i in 0..10) {}" @@ -18,12 +17,12 @@ class NeedBracesCheck extends Check { - WHILE = while body "while (test) {}" - DO_WHILE = do…while body "do {} while (test)" - CATCH = catch body "catch (e:Dynamic) {}" - **/ + **/ public var tokens:Array; /** allow / disallow use of single line statements without braces - **/ + **/ public var allowSingleLineStatement:Bool; public function new() { @@ -94,22 +93,26 @@ class NeedBracesCheck extends Check { function checkFunctionChild(token:TokenTree) { if (token == null || !token.hasChildren()) return; - var accessHelper:TokenTreeAccessHelper; + var body:TokenTree = token; if (token.children.length == 1) { - accessHelper = TokenTreeAccessHelper.access(token).firstChild(); + body = token.getFirstChild(); } - else { - accessHelper = TokenTreeAccessHelper.access(token); + body = TokenTreeAccessHelper.access(body).firstOf(POpen).token; + if ((body == null) || (body.nextSibling == null)) { + return; } - // function bodies - var lastChild:TokenTree = accessHelper.firstOf(BrOpen).token; - if (lastChild != null) return; - // interfaces - lastChild = accessHelper.firstOf(Semicolon).token; - if (lastChild != null) return; - lastChild = accessHelper.lastChild().token; - - checkNoBraces(token, lastChild); + body = body.nextSibling; + if (body.is(DblDot)) { + var lastChild:TokenTree = TokenTreeCheckUtils.getLastToken(token); + if (lastChild.is(Semicolon)) { + return; + } + body = body.nextSibling; + } + if ((body == null) || (body.is(BrOpen))) { + return; + } + checkNoBraces(token, body); } function checkWhileChild(token:TokenTree) { diff --git a/src/checkstyle/checks/block/RightCurlyCheck.hx b/src/checkstyle/checks/block/RightCurlyCheck.hx index bb1086cd..3a4b7a68 100644 --- a/src/checkstyle/checks/block/RightCurlyCheck.hx +++ b/src/checkstyle/checks/block/RightCurlyCheck.hx @@ -2,13 +2,12 @@ package checkstyle.checks.block; /** Checks the placement of right curly braces ("}") for code blocks. The policy to verify is specified using the property "option". - **/ +**/ @name("RightCurly") @desc("Checks the placement of right curly braces (`}`) for code blocks. The policy to verify is specified using the property `option`.") class RightCurlyCheck extends Check { - /** - matches only right curlys specified in tokens list: + matches only right curlys specified in tokens list: - CLASS_DEF = class definition "class Test {}" - ENUM_DEF = enum definition "enum Test {}" - ABSTRACT_DEF = abstract definition "abstract Test {}" @@ -24,15 +23,15 @@ class RightCurlyCheck extends Check { - CATCH = catch body "catch (e:Dynamic) {}" - REIFICATION = macro reification "$i{}" - ARRAY_COMPREHENSION = array comprehension "[for (i in 0...10) {i * 2}]" - **/ + **/ public var tokens:Array; /** - placement of right curly + placement of right curly - same = right curly must be alone on a new line, except for "} else" and "} catch" - alone = alone on a new line - aloneorsingle = right curly can occur on same line as left curly or must be alone on a new line - **/ + **/ public var option:RightCurlyCheckOption; public function new() { @@ -67,8 +66,19 @@ class RightCurlyCheck extends Check { if (isPosSuppressed(brClose.pos)) continue; var brOpen:TokenTree = brClose.parent; if ((brOpen == null) || (brOpen.pos == null)) continue; + var type:BrOpenType = TokenTreeCheckUtils.getBrOpenType(brOpen); + switch (type) { + case BLOCK: + case TYPEDEFDECL: + if (!hasToken(TYPEDEF_DEF)) { + continue; + } + case OBJECTDECL: + case ANONTYPE: + case UNKNOWN: + } if (filterParentToken(brOpen.parent)) continue; - check(brClose, isSingleLine(brOpen.pos.min, brClose.pos.max)); + check(brClose, type, isSingleLine(brOpen.pos.min, brClose.pos.max)); } } @@ -82,7 +92,7 @@ class RightCurlyCheck extends Check { case Kwd(KwdAbstract): return !hasToken(ABSTRACT_DEF); case Kwd(KwdTypedef): - return !hasToken(TYPEDEF_DEF); + return false; case Kwd(KwdEnum): return !hasToken(ENUM_DEF); case Kwd(KwdFunction): @@ -103,19 +113,12 @@ class RightCurlyCheck extends Check { case Kwd(KwdSwitch), Kwd(KwdCase), Kwd(KwdDefault): return !hasToken(SWITCH); case POpen, BkOpen, BrOpen, Kwd(KwdReturn): - return !hasToken(OBJECT_DECL); + return false; case Dollar(_): return !hasToken(REIFICATION); case Binop(OpAssign): // could be OBJECT_DECL or TYPEDEF_DEF - if ((token.parent != null) && (token.parent.parent != null)) { - switch (token.parent.parent.tok) { - case Kwd(KwdTypedef): - return !hasToken(TYPEDEF_DEF); - default: - } - } - return !hasToken(OBJECT_DECL); + return false; default: return filterParentToken(token.parent); } @@ -130,10 +133,10 @@ class RightCurlyCheck extends Check { } } - function check(token:TokenTree, singleLine:Bool) { + function check(token:TokenTree, type:BrOpenType, singleLine:Bool) { var lineNum:Int = checker.getLinePos(token.pos.min).line; var line:String = checker.lines[lineNum]; - checkRightCurly(line, singleLine, token.pos); + checkRightCurly(line, type, singleLine, token.pos); } function isSingleLine(start:Int, end:Int):Bool { @@ -143,7 +146,7 @@ class RightCurlyCheck extends Check { return startLine == endLine; } - function checkRightCurly(line:String, singleLine:Bool, pos:Position) { + function checkRightCurly(line:String, type:BrOpenType, singleLine:Bool, pos:Position) { try { var curlyPos:Position = {file: pos.file, min: pos.min, max: pos.max}; var eof:Bool = false; @@ -171,11 +174,19 @@ class RightCurlyCheck extends Check { logErrorIf(singleLine && (option != ALONE_OR_SINGLELINE), "Right curly should not be on same line as left curly", curlyPos); if (singleLine) return; - var curlyAlone:Bool = ~/^\s*\}(|\..*|\).*|\].*|,\s*|;\s*)(|\/\/.*)$/.match(line); + var curlyAlone:Bool = false; + + switch (type) { + case BLOCK, TYPEDEFDECL, UNKNOWN: + curlyAlone = ~/^\s*\}(|\..*|\).*|\].*|,\s*|;\s*)(|\/\/.*)$/.match(line); + case OBJECTDECL, ANONTYPE: + curlyAlone = ~/^\s*\}(|\..*|\).*|\].*|,.*|;\s*)(|\/\/.*)$/.match(line); + } logErrorIf(!curlyAlone && (option == ALONE_OR_SINGLELINE || option == ALONE), "Right curly should be alone on a new line", curlyPos); logErrorIf(curlyAlone && needsSameOption, "Right curly should be alone on a new line", curlyPos); logErrorIf(needsSameOption && (option != SAME), "Right curly must not be on same line as following block", curlyPos); - logErrorIf(shouldHaveSameOption && (option == SAME), 'Right curly should be on same line as following block (e.g. "} else" or "} catch")', curlyPos); + logErrorIf(shouldHaveSameOption && (option == SAME), 'Right curly should be on same line as following block (e.g. "} else" or "} catch")', + curlyPos); } catch (e:String) { // one of the error messages fired -> do nothing @@ -190,53 +201,53 @@ class RightCurlyCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [{ - propertyName: "tokens", - value: [ - CLASS_DEF, - ENUM_DEF, - ABSTRACT_DEF, - TYPEDEF_DEF, - INTERFACE_DEF, - OBJECT_DECL, - FUNCTION, - FOR, - WHILE, - SWITCH, - TRY, - CATCH - ] - }], - properties: [{ - propertyName: "option", - values: [ALONE_OR_SINGLELINE, ALONE, SAME] - }] - }, - { - fixed: [{ - propertyName: "tokens", - value: [ - IF, - ] - }], - properties: [{ - propertyName: "option", - values: [ALONE_OR_SINGLELINE, ALONE, SAME] - }] - }, - { - fixed: [{ - propertyName: "tokens", - value: [ - OBJECT_DECL - ] - }], - properties: [{ - propertyName: "option", - values: [ALONE_OR_SINGLELINE, ALONE, SAME] - }] - }]; + return [ + { + fixed: [ + { + propertyName: "tokens", + value: [ + CLASS_DEF, + ENUM_DEF, + ABSTRACT_DEF, + TYPEDEF_DEF, + INTERFACE_DEF, + OBJECT_DECL, + FUNCTION, + FOR, + WHILE, + SWITCH, + TRY, + CATCH + ] + } + ], + properties: [{ + propertyName: "option", + values: [ALONE_OR_SINGLELINE, ALONE, SAME] + }] + }, + { + fixed: [{ + propertyName: "tokens", + value: [IF] + }], + properties: [{ + propertyName: "option", + values: [ALONE_OR_SINGLELINE, ALONE, SAME] + }] + }, + { + fixed: [{ + propertyName: "tokens", + value: [OBJECT_DECL] + }], + properties: [{ + propertyName: "option", + values: [ALONE_OR_SINGLELINE, ALONE, SAME] + }] + } + ]; } } @@ -247,7 +258,6 @@ abstract RightCurlyCheckToken(String) { var ABSTRACT_DEF = "ABSTRACT_DEF"; var TYPEDEF_DEF = "TYPEDEF_DEF"; var INTERFACE_DEF = "INTERFACE_DEF"; - var OBJECT_DECL = "OBJECT_DECL"; var FUNCTION = "FUNCTION"; var FOR = "FOR"; diff --git a/src/checkstyle/checks/coding/AvoidInlineConditionalsCheck.hx b/src/checkstyle/checks/coding/AvoidInlineConditionalsCheck.hx index c8210877..099ad190 100644 --- a/src/checkstyle/checks/coding/AvoidInlineConditionalsCheck.hx +++ b/src/checkstyle/checks/coding/AvoidInlineConditionalsCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.coding; /** Detects inline conditionals. Useful for developers who find inline conditionals hard to read and want forbid them. - **/ +**/ @name("AvoidInlineConditionals") @desc("Detects inline conditionals. Useful for developers who find inline conditionals hard to read and want forbid them.") class AvoidInlineConditionalsCheck extends Check { - public function new() { super(AST); severity = SeverityLevel.IGNORE; @@ -17,8 +16,9 @@ class AvoidInlineConditionalsCheck extends Check { override function actualRun() { checker.ast.walkFile(function(e:Expr) { if (isPosSuppressed(e.pos)) return; - switch (e.expr){ - case ETernary(econd, eif, eelse): logPos("Avoid inline conditionals", e.pos); + switch (e.expr) { + case ETernary(econd, eif, eelse): + logPos("Avoid inline conditionals", e.pos); default: } }); diff --git a/src/checkstyle/checks/coding/DefaultComesLastCheck.hx b/src/checkstyle/checks/coding/DefaultComesLastCheck.hx index 0d0e11f8..36c48634 100644 --- a/src/checkstyle/checks/coding/DefaultComesLastCheck.hx +++ b/src/checkstyle/checks/coding/DefaultComesLastCheck.hx @@ -3,11 +3,10 @@ package checkstyle.checks.coding; /** Check that the "default" is after all the cases in a "switch" statement. Haxe allows "default" anywhere within the "switch" statement. But it is more readable if it comes after the last "case". - **/ +**/ @name("DefaultComesLast") @desc("Check that the `default` is after all the cases in a `switch` statement. Haxe allows `default` anywhere within the `switch` statement. But it is more readable if it comes after the last `case`.") class DefaultComesLastCheck extends Check { - public function new() { super(TOKEN); categories = [Category.STYLE, Category.CLARITY]; diff --git a/src/checkstyle/checks/coding/HiddenFieldCheck.hx b/src/checkstyle/checks/coding/HiddenFieldCheck.hx index 97cfdd59..26094ccf 100644 --- a/src/checkstyle/checks/coding/HiddenFieldCheck.hx +++ b/src/checkstyle/checks/coding/HiddenFieldCheck.hx @@ -2,26 +2,25 @@ package checkstyle.checks.coding; /** Checks that a local variable or a parameter does not shadow a field that is defined in the same class. - **/ +**/ @name("HiddenField") @desc("Checks that a local variable or a parameter does not shadow a field that is defined in the same class.") class HiddenFieldCheck extends Check { - static inline var MAX_FIELD_LEVEL:Int = 3; /** allow constructor parameters to shadow field names - **/ + **/ public var ignoreConstructorParameter:Bool; /** allow setters to shadow field names - **/ + **/ public var ignoreSetter:Bool; /** ignore function names matching "ignoreFormat" regex - **/ + **/ public var ignoreFormat:String; public function new() { @@ -59,8 +58,10 @@ class HiddenFieldCheck extends Check { if (methodName.is(Kwd(KwdNew)) && ignoreConstructorParameter) return; if (ignoreSetter && isSetterFunction(methodName, memberNames)) return; switch (methodName.tok) { - case Const(CIdent(name)): if (ignoreFormatRE.match(name)) return; - case Kwd(KwdNew): if (ignoreFormatRE.match("new")) return; + case Const(CIdent(name)): + if (ignoreFormatRE.match(name)) return; + case Kwd(KwdNew): + if (ignoreFormatRE.match("new")) return; default: } @@ -136,7 +137,8 @@ class HiddenFieldCheck extends Check { for (member in varFields) { if (!member.hasChildren()) continue; switch (member.children[0].tok) { - case Const(CIdent(name)): memberNames.push(name); + case Const(CIdent(name)): + memberNames.push(name); default: } } @@ -144,16 +146,20 @@ class HiddenFieldCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "ignoreConstructorParameter", - values: [true, false] - }, + return [ { - propertyName: "ignoreSetter", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "ignoreConstructorParameter", + values: [true, false] + }, + { + propertyName: "ignoreSetter", + values: [true, false] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/coding/InnerAssignmentCheck.hx b/src/checkstyle/checks/coding/InnerAssignmentCheck.hx index d326c66b..6bf41620 100644 --- a/src/checkstyle/checks/coding/InnerAssignmentCheck.hx +++ b/src/checkstyle/checks/coding/InnerAssignmentCheck.hx @@ -2,14 +2,13 @@ package checkstyle.checks.coding; /** Checks for assignments in subexpressions, such as in "if ((a=b) > 0) return;". - **/ +**/ @name("InnerAssignment") @desc("Checks for assignments in subexpressions, such as in `if ((a=b) > 0) return;`.") class InnerAssignmentCheck extends Check { - /** ignores assignments in return statements - **/ + **/ public var ignoreReturnAssignments:Bool; public function new() { @@ -105,19 +104,22 @@ class InnerAssignmentCheck extends Check { switch (parent.tok) { case Const(CIdent(name)): if (!StringTools.startsWith(name, "set_")) return true; - default: return true; + default: + return true; } return false; } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "ignoreReturnAssignments", - values: [false, true] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "ignoreReturnAssignments", + values: [false, true] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/coding/MagicNumberCheck.hx b/src/checkstyle/checks/coding/MagicNumberCheck.hx index c60e3416..0ff59f72 100644 --- a/src/checkstyle/checks/coding/MagicNumberCheck.hx +++ b/src/checkstyle/checks/coding/MagicNumberCheck.hx @@ -6,10 +6,9 @@ package checkstyle.checks.coding; @name("MagicNumber") @desc("Checks that there are no magic numbers. By default, -1, 0, 1, and 2 are not considered to be magic numbers.") class MagicNumberCheck extends Check { - /** list of magic numbers to ignore during checks - **/ + **/ public var ignoreNumbers:Array; public function new() { @@ -21,7 +20,13 @@ class MagicNumberCheck extends Check { override function actualRun() { var root:TokenTree = checker.getTokenTree(); - var allTypes:Array = root.filter([Kwd(KwdAbstract), Kwd(KwdClass), Kwd(KwdEnum), Kwd(KwdInterface), Kwd(KwdTypedef)], FIRST); + var allTypes:Array = root.filter([ + Kwd(KwdAbstract), + Kwd(KwdClass), + Kwd(KwdEnum), + Kwd(KwdInterface), + Kwd(KwdTypedef) + ], FIRST); for (type in allTypes) { if (TokenTreeCheckUtils.isTypeEnumAbstract(type)) continue; checkForNumbers(type); @@ -59,9 +64,7 @@ class MagicNumberCheck extends Check { if ((token == null) || (token.tok == null)) return true; return switch (token.tok) { case At: false; - case Kwd(KwdVar): - if (token.filter([Kwd(KwdStatic)], FIRST).length > 0) false; - else true; + case Kwd(KwdVar): if (token.filter([Kwd(KwdStatic)], FIRST).length > 0) false; else true; default: filterNumber(token.parent); } } diff --git a/src/checkstyle/checks/coding/MultipleVariableDeclarationsCheck.hx b/src/checkstyle/checks/coding/MultipleVariableDeclarationsCheck.hx index c6a2a2eb..73b3f956 100644 --- a/src/checkstyle/checks/coding/MultipleVariableDeclarationsCheck.hx +++ b/src/checkstyle/checks/coding/MultipleVariableDeclarationsCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.coding; /** Checks that each variable declaration is in its own statement and on its own line. - **/ +**/ @name("MultipleVariableDeclarations") @desc("Checks that each variable declaration is in its own statement and on its own line.") class MultipleVariableDeclarationsCheck extends Check { - public function new() { super(TOKEN); categories = [Category.STYLE, Category.CLARITY, Category.COMPLEXITY]; diff --git a/src/checkstyle/checks/coding/NestedForDepthCheck.hx b/src/checkstyle/checks/coding/NestedForDepthCheck.hx index 5d9810f7..d208ca13 100644 --- a/src/checkstyle/checks/coding/NestedForDepthCheck.hx +++ b/src/checkstyle/checks/coding/NestedForDepthCheck.hx @@ -2,15 +2,14 @@ package checkstyle.checks.coding; /** Restricts nested loop blocks to a specified depth (default = 1). - **/ +**/ @name("NestedForDepth") @desc("Restricts nested loop blocks to a specified depth (default = 1).") class NestedForDepthCheck extends Check { - /** maximum number of nested loops allowed setting "max" to 1 allows one inner loop - **/ + **/ public var max:Int; public function new() { diff --git a/src/checkstyle/checks/coding/NestedIfDepthCheck.hx b/src/checkstyle/checks/coding/NestedIfDepthCheck.hx index 6fe15b4e..6c683a17 100644 --- a/src/checkstyle/checks/coding/NestedIfDepthCheck.hx +++ b/src/checkstyle/checks/coding/NestedIfDepthCheck.hx @@ -2,15 +2,14 @@ package checkstyle.checks.coding; /** Restricts nested "if-else" blocks to a specified depth (default = 1). - **/ +**/ @name("NestedIfDepth") @desc("Restricts nested `if-else` blocks to a specified depth (default = 1).") class NestedIfDepthCheck extends Check { - /** maximum number of nested if statements allowed setting "max" to 1 allows one if inside another - **/ + **/ public var max:Int; public function new() { diff --git a/src/checkstyle/checks/coding/NestedTryDepthCheck.hx b/src/checkstyle/checks/coding/NestedTryDepthCheck.hx index 5f64e971..c448b83c 100644 --- a/src/checkstyle/checks/coding/NestedTryDepthCheck.hx +++ b/src/checkstyle/checks/coding/NestedTryDepthCheck.hx @@ -2,15 +2,14 @@ package checkstyle.checks.coding; /** Restricts nested "try" blocks to a specified depth (default = 1). - **/ +**/ @name("NestedTryDepth") @desc("Restricts nested `try` blocks to a specified depth (default = 1).") class NestedTryDepthCheck extends Check { - /** maximum number of nested try/catch statemenmts allowed setting "max" to 1 allows one inner try/catch - **/ + **/ public var max:Int; public function new() { diff --git a/src/checkstyle/checks/coding/NullableParameterCheck.hx b/src/checkstyle/checks/coding/NullableParameterCheck.hx index 3e4d27a3..84d8610d 100644 --- a/src/checkstyle/checks/coding/NullableParameterCheck.hx +++ b/src/checkstyle/checks/coding/NullableParameterCheck.hx @@ -4,16 +4,15 @@ using haxe.macro.ExprTools; /** Enforces a style for nullable parameters. - **/ +**/ @name("NullableParameter") @desc("Enforces a style for nullable parameters.") class NullableParameterCheck extends Check { - /** nullable style to enforece - questionMark = nullable parameters should use "?name:Type" - nullDefault = nullable parameters should use "name:Type = null" - **/ + **/ public var option:NullableParameterCheckOption; public function new() { @@ -49,20 +48,22 @@ class NullableParameterCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "option", - values: [QUESTION_MARK, NULL_DEFAULT] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "option", + values: [QUESTION_MARK, NULL_DEFAULT] + }] + } + ]; } } /** - questionMark = nullable parameters should use "?name:Type" - nullDefault = nullable parameters should use "name:Type = null" - **/ +**/ @:enum abstract NullableParameterCheckOption(String) { var QUESTION_MARK = "questionMark"; diff --git a/src/checkstyle/checks/coding/ReturnCountCheck.hx b/src/checkstyle/checks/coding/ReturnCountCheck.hx index 124c3bb6..9f929112 100644 --- a/src/checkstyle/checks/coding/ReturnCountCheck.hx +++ b/src/checkstyle/checks/coding/ReturnCountCheck.hx @@ -2,19 +2,18 @@ package checkstyle.checks.coding; /** Restricts the number of return statements in methods (2 by default). Ignores methods that matches "ignoreFormat" regex property. - **/ +**/ @name("ReturnCount") @desc("Restricts the number of return statements in methods (2 by default). Ignores methods that matches `ignoreFormat` regex property.") class ReturnCountCheck extends Check { - /** maximum number of return calls a function may have - **/ + **/ public var max:Int; /** ignore function names matching "ignoreFormat" regex - **/ + **/ public var ignoreFormat:String; public function new() { @@ -49,8 +48,7 @@ class ReturnCountCheck extends Check { return switch (token.tok) { case Kwd(KwdFunction): // top node is always a function node - if (depth == 0) GO_DEEPER; - else SKIP_SUBTREE; + if (depth == 0) GO_DEEPER; else SKIP_SUBTREE; case Kwd(KwdReturn): FOUND_SKIP_SUBTREE; default: GO_DEEPER; } diff --git a/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx b/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx index 405f1744..b8e30912 100644 --- a/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx +++ b/src/checkstyle/checks/coding/SimplifyBooleanExpressionCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.coding; /** Checks for over-complicated boolean expressions. Finds code like "if (b == true), b || true, !false", etc. - **/ +**/ @name("SimplifyBooleanExpression") @desc("Checks for over-complicated boolean expressions. Finds code like `if (b == true), b || true, !false`, etc.") class SimplifyBooleanExpressionCheck extends Check { - public function new() { super(TOKEN); categories = [Category.COMPLEXITY]; @@ -35,10 +34,10 @@ class SimplifyBooleanExpressionCheck extends Check { function checkToken(token:TokenTree) { var parent = token.parent; - if (parent.is(Binop(OpEq)) || parent.is(Binop(OpNotEq)) || parent.is(Unop(OpNot)) || - parent.is(Binop(OpOr)) || parent.is(Binop(OpAnd)) || parent.is(Binop(OpBoolOr)) || - parent.is(Binop(OpBoolAnd))) { - logPos("Boolean expression can be simplified", token.pos); + switch (parent.tok) { + case Binop(OpEq), Binop(OpNotEq), Unop(OpNot), Binop(OpOr), Binop(OpAnd), Binop(OpBoolOr), Binop(OpBoolAnd): + logPos("Boolean expression can be simplified", token.pos); + default: } } } \ No newline at end of file diff --git a/src/checkstyle/checks/coding/SimplifyBooleanReturnCheck.hx b/src/checkstyle/checks/coding/SimplifyBooleanReturnCheck.hx index 423b15df..90d258bd 100644 --- a/src/checkstyle/checks/coding/SimplifyBooleanReturnCheck.hx +++ b/src/checkstyle/checks/coding/SimplifyBooleanReturnCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.coding; /** Checks for over-complicated boolean return statements. - **/ +**/ @name("SimplifyBooleanReturn") @desc("Checks for over-complicated boolean return statements.") class SimplifyBooleanReturnCheck extends Check { - public function new() { super(TOKEN); categories = [Category.COMPLEXITY]; diff --git a/src/checkstyle/checks/coding/TraceCheck.hx b/src/checkstyle/checks/coding/TraceCheck.hx index d7de31ec..9d8f7ce3 100644 --- a/src/checkstyle/checks/coding/TraceCheck.hx +++ b/src/checkstyle/checks/coding/TraceCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.coding; /** Checks for trace calls in code. - **/ +**/ @name("Trace") @desc("Checks for trace calls in code.") class TraceCheck extends Check { - public function new() { super(TOKEN); severity = SeverityLevel.IGNORE; @@ -33,12 +32,14 @@ class TraceCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/coding/UnusedLocalVarCheck.hx b/src/checkstyle/checks/coding/UnusedLocalVarCheck.hx index ce828396..4cb0dd1e 100644 --- a/src/checkstyle/checks/coding/UnusedLocalVarCheck.hx +++ b/src/checkstyle/checks/coding/UnusedLocalVarCheck.hx @@ -4,11 +4,10 @@ import checkstyle.utils.StringUtils; /** Checks for unused local variables. - **/ +**/ @name("UnusedLocalVar") @desc("Checks for unused local variables.") class UnusedLocalVarCheck extends Check { - public function new() { super(TOKEN); } @@ -68,8 +67,7 @@ class UnusedLocalVarCheck extends Check { } return switch (tok.tok) { case Const(CIdent(n)): - if (n == name) FOUND_GO_DEEPER; - else GO_DEEPER; + if (n == name) FOUND_GO_DEEPER; else GO_DEEPER; case Const(CString(s)): checkStringInterpolation(tok, name, s); default: GO_DEEPER; @@ -102,12 +100,14 @@ class UnusedLocalVarCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/coding/VariableInitialisationCheck.hx b/src/checkstyle/checks/coding/VariableInitialisationCheck.hx index 01b323dc..ce86252d 100644 --- a/src/checkstyle/checks/coding/VariableInitialisationCheck.hx +++ b/src/checkstyle/checks/coding/VariableInitialisationCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.coding; /** Checks for instance variables that are initialised at class level. - **/ +**/ @name("VariableInitialisation") @desc("Checks for instance variables that are initialised at class level.") class VariableInitialisationCheck extends Check { - public function new() { super(AST); categories = [Category.STYLE, Category.CLARITY]; diff --git a/src/checkstyle/checks/comments/DocCommentStyleCheck.hx b/src/checkstyle/checks/comments/DocCommentStyleCheck.hx index 79d70d25..e17c0cb8 100644 --- a/src/checkstyle/checks/comments/DocCommentStyleCheck.hx +++ b/src/checkstyle/checks/comments/DocCommentStyleCheck.hx @@ -2,25 +2,25 @@ package checkstyle.checks.comments; /** Checks code documentation style (/** vs /*) - **/ +**/ @name("DocCommentStyle") @desc("Checks code documentation style (/**…**/ vs /*…*/)") class DocCommentStyleCheck extends Check { - /** - Defines how doc comments should start / end: + Defines how doc comments should start / end: - ignore = accepts any start / end - onestar = /* - twostar = /** - **/ + **/ public var startStyle:DocCommentStyle; + /** Defines how each doc comments line should start: - ignore = accepts any line prefix - none = - onestar = * - twostar = ** - **/ + **/ public var lineStyle:DocCommentStyle; public function new() { @@ -46,7 +46,8 @@ class DocCommentStyleCheck extends Check { var prevToken:TokenTree = token.previousSibling; if (prevToken == null) continue; switch (prevToken.tok) { - case Comment(text): checkCommentStyle(prevToken, text); + case Comment(text): + checkCommentStyle(prevToken, text); default: } } @@ -85,27 +86,31 @@ class DocCommentStyleCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "startStyle", - values: [ONE_STAR, TWO_STARS] - }, + return [ { - propertyName: "lineStyle", - values: [NONE, ONE_STAR, TWO_STARS] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "startStyle", + values: [ONE_STAR, TWO_STARS] + }, + { + propertyName: "lineStyle", + values: [NONE, ONE_STAR, TWO_STARS] + } + ] + } + ]; } } /** - styles for comment lines and start / stop: + styles for comment lines and start / stop: - ignore = accepts any line prefix - none = - onestar = * - twostar = ** - **/ +**/ @:enum abstract DocCommentStyle(String) { var IGNORE = "ignore"; diff --git a/src/checkstyle/checks/comments/FieldDocCommentCheck.hx b/src/checkstyle/checks/comments/FieldDocCommentCheck.hx index c2402a9b..d54c3583 100644 --- a/src/checkstyle/checks/comments/FieldDocCommentCheck.hx +++ b/src/checkstyle/checks/comments/FieldDocCommentCheck.hx @@ -4,60 +4,59 @@ import checkstyle.checks.comments.TypeDocCommentCheck.TypeDocCommentToken; /** Checks code documentation on type level - **/ +**/ @name("FieldDocComment") @desc("Checks code documentation on fields") class FieldDocCommentCheck extends Check { - /** - matches only comment docs for types specified in tokens list: + matches only comment docs for types specified in tokens list: - ABSTRACT_DEF = abstract definition "abstract Test {}" - CLASS_DEF = class definition "class Test {}" - ENUM_DEF = enum definition "enum Test {}" - INTERFACE_DEF = interface definition "interface Test {}" - TYPEDEF_DEF = typdef definition "typedef Test = {}" - **/ + **/ public var tokens:Array; + /** only check fields of type - VARS = only var fields - FUNCTIONS = only functions; - BOTH = both vars and functions; - **/ + **/ public var fieldType:FieldDocCommentType; + /** only check fields matching modifier - PUBLIC = only public fields - PRIVATE = only private fields - BOTH = public and private fields - **/ + **/ public var modifier:FieldDocCommentModifier; + /** ignores requires a `@param` tag for every parameter - **/ + **/ public var requireParams:Bool; + /** ignores requires a `@return` tag - **/ + **/ public var requireReturn:Bool; + /** ignores methods marked with override - **/ + **/ public var ignoreOverride:Bool; + /** exclude field names from check - default: ["new", "toString"] - **/ + **/ public var excludeNames:Array; public function new() { super(TOKEN); - tokens = [ - ABSTRACT_DEF, - CLASS_DEF, - ENUM_DEF, - INTERFACE_DEF, - TYPEDEF_DEF - ]; + tokens = [ABSTRACT_DEF, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, TYPEDEF_DEF]; fieldType = BOTH; modifier = PUBLIC; requireParams = true; @@ -95,10 +94,14 @@ class FieldDocCommentCheck extends Check { function isDefaultPublic(token:TokenTree):Bool { switch (token.tok) { - case Kwd(KwdAbstract): return true; - case Kwd(KwdInterface): return true; - case Kwd(KwdTypedef): return true; - default: return false; + case Kwd(KwdAbstract): + return true; + case Kwd(KwdInterface): + return true; + case Kwd(KwdTypedef): + return true; + default: + return false; } } @@ -114,7 +117,8 @@ class FieldDocCommentCheck extends Check { return; } switch (prevToken.tok) { - case Comment(text): checkComment(name, token, prevToken, text); + case Comment(text): + checkComment(name, token, prevToken, text); default: } } @@ -132,8 +136,10 @@ class FieldDocCommentCheck extends Check { var isPublic:Bool = defaultPublic; for (modToken in modifierList) { switch (modToken.tok) { - case Kwd(KwdPublic): isPublic = true; - case Kwd(KwdPrivate): isPublic = false; + case Kwd(KwdPublic): + isPublic = true; + case Kwd(KwdPrivate): + isPublic = false; default: } } @@ -145,9 +151,12 @@ class FieldDocCommentCheck extends Check { var nameTok:TokenTree = TokenTreeAccessHelper.access(token).firstChild().token; if (nameTok == null) return ""; switch (nameTok.tok) { - case Const(CIdent(text)): return text; - case Kwd(KwdNew): return "new"; - default: return ""; + case Const(CIdent(text)): + return text; + case Kwd(KwdNew): + return "new"; + default: + return ""; } } @@ -165,13 +174,14 @@ class FieldDocCommentCheck extends Check { if ((firstLine == "") || (firstLine == "*")) logPos('Documentation for field "$name" should have at least one extra line of text', docToken.pos); switch (token.tok) { - case Kwd(KwdFunction): checkFunctionComment(name, token, docToken, text); + case Kwd(KwdFunction): + checkFunctionComment(name, token, docToken, text); default: } } function checkFunctionComment(name:String, token:TokenTree, docToken:TokenTree, text:String) { - if (requireParams) checkParams (name, token, docToken, text); + if (requireParams) checkParams(name, token, docToken, text); if (!requireReturn) return; var access:TokenTreeAccessHelper = TokenTreeAccessHelper.access(token).firstChild().firstOf(DblDot); @@ -191,7 +201,8 @@ class FieldDocCommentCheck extends Check { if (popenToken.children != null) { for (child in popenToken.children) { switch (child.tok) { - case Const(CIdent(ident)): params.push(ident); + case Const(CIdent(ident)): + params.push(ident); default: } } @@ -259,37 +270,41 @@ class FieldDocCommentCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "tokens", - values: [[ABSTRACT_DEF, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, TYPEDEF_DEF]] - }, - { - propertyName: "excludeNames", - values: [["new", "toString"]] - }, - { - propertyName: "modifier", - values: [PUBLIC, BOTH, PRIVATE] - }, - { - propertyName: "fieldType", - values: [BOTH, FUNCTIONS, VARS] - }, + return [ { - propertyName: "requireParams", - values: [true, false] - }, - { - propertyName: "requireReturn", - values: [true, false] - }, - { - propertyName: "ignoreOverride", - values: [false, true] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "tokens", + values: [[ABSTRACT_DEF, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, TYPEDEF_DEF]] + }, + { + propertyName: "excludeNames", + values: [["new", "toString"]] + }, + { + propertyName: "modifier", + values: [PUBLIC, BOTH, PRIVATE] + }, + { + propertyName: "fieldType", + values: [BOTH, FUNCTIONS, VARS] + }, + { + propertyName: "requireParams", + values: [true, false] + }, + { + propertyName: "requireReturn", + values: [true, false] + }, + { + propertyName: "ignoreOverride", + values: [false, true] + } + ] + } + ]; } } @@ -298,7 +313,7 @@ class FieldDocCommentCheck extends Check { - VARS = only var fields - FUNCTIONS = only functions; - BOTH = both vars and functions; - **/ +**/ @:enum abstract FieldDocCommentType(String) { var VARS = "VARS"; @@ -311,7 +326,7 @@ abstract FieldDocCommentType(String) { - PUBLIC = only public fields - PRIVATE = only private fields - BOTH = public and private fields - **/ +**/ @:enum abstract FieldDocCommentModifier(String) { var PUBLIC = "PUBLIC"; diff --git a/src/checkstyle/checks/comments/TODOCommentCheck.hx b/src/checkstyle/checks/comments/TODOCommentCheck.hx index 65daf3bd..23823218 100644 --- a/src/checkstyle/checks/comments/TODOCommentCheck.hx +++ b/src/checkstyle/checks/comments/TODOCommentCheck.hx @@ -2,14 +2,13 @@ package checkstyle.checks.comments; /** A check for TODO/FIXME/HACK/XXX/BUG comments. The format can be customised by changing `format` property. - **/ +**/ @name("TODOComment") @desc("A check for TODO/FIXME/HACK/XXX/BUG comments. The format can be customised by changing `format` property.") class TODOCommentCheck extends Check { - /** regex todo comment format, defaults to "^\\s*(TODO|FIXME|HACK|XXX|BUG)" - **/ + **/ public var format:String; public function new() { @@ -32,12 +31,14 @@ class TODOCommentCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "format", - values: ["^\\s*(TODO|FIXME|HACK|XXX|BUG)"] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "format", + values: ["^\\s*(TODO|FIXME|HACK|XXX|BUG)"] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/comments/TypeDocCommentCheck.hx b/src/checkstyle/checks/comments/TypeDocCommentCheck.hx index 884d5a4f..5e425739 100644 --- a/src/checkstyle/checks/comments/TypeDocCommentCheck.hx +++ b/src/checkstyle/checks/comments/TypeDocCommentCheck.hx @@ -2,30 +2,23 @@ package checkstyle.checks.comments; /** Checks code documentation on type level - **/ +**/ @name("TypeDocComment") @desc("Checks code documentation on type level") class TypeDocCommentCheck extends Check { - /** - matches only comment docs for types specified in tokens list: + matches only comment docs for types specified in tokens list: - ABSTRACT_DEF = abstract definition "abstract Test {}" - CLASS_DEF = class definition "class Test {}" - ENUM_DEF = enum definition "enum Test {}" - INTERFACE_DEF = interface definition "interface Test {}" - TYPEDEF_DEF = typdef definition "typedef Test = {}" - **/ + **/ public var tokens:Array; public function new() { super(TOKEN); - tokens = [ - ABSTRACT_DEF, - CLASS_DEF, - ENUM_DEF, - INTERFACE_DEF, - TYPEDEF_DEF - ]; + tokens = [ABSTRACT_DEF, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, TYPEDEF_DEF]; } function hasToken(token:TypeDocCommentToken):Bool { @@ -51,7 +44,8 @@ class TypeDocCommentCheck extends Check { continue; } switch (prevToken.tok) { - case Comment(text): checkComment(name, prevToken, text); + case Comment(text): + checkComment(name, prevToken, text); default: } } @@ -61,8 +55,10 @@ class TypeDocCommentCheck extends Check { var nameTok:TokenTree = TokenTreeAccessHelper.access(token).firstChild().token; if (nameTok == null) return ""; switch (nameTok.tok) { - case Const(CIdent(text)): return text; - default: return ""; + case Const(CIdent(text)): + return text; + default: + return ""; } } @@ -81,13 +77,17 @@ class TypeDocCommentCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "tokens", - values: [[ABSTRACT_DEF, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, TYPEDEF_DEF]] - }] - }]; + return [ + { + fixed: [], + properties: [ + { + propertyName: "tokens", + values: [[ABSTRACT_DEF, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, TYPEDEF_DEF]] + } + ] + } + ]; } } diff --git a/src/checkstyle/checks/design/EmptyPackageCheck.hx b/src/checkstyle/checks/design/EmptyPackageCheck.hx index a9a35e63..1e0558a8 100644 --- a/src/checkstyle/checks/design/EmptyPackageCheck.hx +++ b/src/checkstyle/checks/design/EmptyPackageCheck.hx @@ -2,14 +2,13 @@ package checkstyle.checks.design; /** Checks for empty package names. - **/ +**/ @name("EmptyPackage") @desc("Checks for empty package names.") class EmptyPackageCheck extends Check { - /** enforce using a package declaration, even if it is empty - **/ + **/ public var enforceEmptyPackage:Bool; public function new() { @@ -34,13 +33,15 @@ class EmptyPackageCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "enforceEmptyPackage", - values: [true, false] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "enforceEmptyPackage", + values: [true, false] + }] + } + ]; } } diff --git a/src/checkstyle/checks/design/InterfaceCheck.hx b/src/checkstyle/checks/design/InterfaceCheck.hx index 0b6ee2be..9f6b6216 100644 --- a/src/checkstyle/checks/design/InterfaceCheck.hx +++ b/src/checkstyle/checks/design/InterfaceCheck.hx @@ -2,19 +2,18 @@ package checkstyle.checks.design; /** Checks and enforces interface style. Either to allow properties and methods or just methods. Has an option to "allowMarkerInterfaces". - **/ +**/ @name("Interface") @desc("Checks and enforces interface style. Either to allow properties and methods or just methods. Has an option to `allowMarkerInterfaces`.") class InterfaceCheck extends Check { - /** allows empty marker interfaces, or forbid their use - **/ + **/ public var allowMarkerInterfaces:Bool; /** allow properties inside interface types - **/ + **/ public var allowProperties:Bool; public function new() { @@ -42,16 +41,20 @@ class InterfaceCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "allowMarkerInterfaces", - values: [true, false] - }, + return [ { - propertyName: "allowProperties", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "allowMarkerInterfaces", + values: [true, false] + }, + { + propertyName: "allowProperties", + values: [true, false] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/design/UnnecessaryConstructorCheck.hx b/src/checkstyle/checks/design/UnnecessaryConstructorCheck.hx index 846412fa..4f1d8222 100644 --- a/src/checkstyle/checks/design/UnnecessaryConstructorCheck.hx +++ b/src/checkstyle/checks/design/UnnecessaryConstructorCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.design; /** Checks for unnecessary constructor in classes that contain only static methods or fields. - **/ +**/ @name("UnnecessaryConstructor") @desc("Checks for unnecessary constructor in classes that contain only static methods or fields.") class UnnecessaryConstructorCheck extends Check { - public function new() { super(TOKEN); categories = [Category.BUG_RISK]; @@ -20,10 +19,7 @@ class UnnecessaryConstructorCheck extends Check { if (extendsBaseClass(cls)) { continue; } - var acceptableTokens:Array = cls.filter([ - Kwd(KwdFunction), - Kwd(KwdVar) - ], FIRST); + var acceptableTokens:Array = cls.filter([Kwd(KwdFunction), Kwd(KwdVar)], FIRST); var haveConstructor:Bool = false; var staticTokens:Int = 0; @@ -58,12 +54,14 @@ class UnnecessaryConstructorCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/imports/AvoidStarImportCheck.hx b/src/checkstyle/checks/imports/AvoidStarImportCheck.hx index f5f1e258..de39d043 100644 --- a/src/checkstyle/checks/imports/AvoidStarImportCheck.hx +++ b/src/checkstyle/checks/imports/AvoidStarImportCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.imports; /** Checks for import statements that use the * notation and using directives. - **/ +**/ @name("AvoidStarImport") @desc("Checks for import statements that use the * notation and using directives.") class AvoidStarImportCheck extends Check { - public function new() { super(TOKEN); categories = [Category.STYLE, Category.CLARITY]; @@ -27,12 +26,14 @@ class AvoidStarImportCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/imports/UnusedImportCheck.hx b/src/checkstyle/checks/imports/UnusedImportCheck.hx index 9b42356a..af9e0271 100644 --- a/src/checkstyle/checks/imports/UnusedImportCheck.hx +++ b/src/checkstyle/checks/imports/UnusedImportCheck.hx @@ -5,20 +5,19 @@ import haxe.io.Path; /** Checks for unused or duplicate imports. - **/ +**/ @name("UnusedImport") @desc("Checks for unused or duplicate imports.") class UnusedImportCheck extends Check { - /** list of module names to ignore, any module from "ignoreModules" won't show up as unused in any file during a run - **/ + **/ public var ignoreModules:Array; /** modules that define multiple types may show up as unused, unless "moduleTypeMap" contains a mapping for it e.g. "haxe.macro.Expr": ["ExprDef", "ComplexType"] - would allow "import haxe.macro.Expr;" even though you just use "ComplexType" - **/ + **/ public var moduleTypeMap:Any; public function new() { @@ -48,7 +47,7 @@ class UnusedImportCheck extends Check { switch (token.tok) { case Const(CString(text)): if (checker.getString(token.pos.min, token.pos.min + 1) != "'") return GO_DEEPER; - if (~/\$\{[^\}]+\.[^\}]+\}/.match (text)) return FOUND_GO_DEEPER; + if (~/\$\{[^\}]+\.[^\}]+\}/.match(text)) return FOUND_GO_DEEPER; default: } return GO_DEEPER; @@ -100,10 +99,12 @@ class UnusedImportCheck extends Check { while (true) { switch (token.tok) { - case Binop(OpMult): return null; + case Binop(OpMult): + return null; case Kwd(KwdImport): case Kwd(KwdPackage): - case Semicolon: return moduleName.toString(); + case Semicolon: + return moduleName.toString(); #if (haxe_ver < 4.0) case Kwd(KwdIn): if (token.parent.tok.match(Dot)) moduleName.add(token.toString()); @@ -116,7 +117,8 @@ class UnusedImportCheck extends Check { case Const(CIdent("as")): if (token.parent.tok.match(Dot)) moduleName.add(token.toString()); else moduleName.add(" as "); - default: moduleName.add(token.toString()); + default: + moduleName.add(token.toString()); } token = token.getFirstChild(); } @@ -127,10 +129,12 @@ class UnusedImportCheck extends Check { var lastName:String = null; while (true) { switch (token.tok) { - case Binop(OpMult): return null; + case Binop(OpMult): + return null; case Const(CIdent(name)): lastName = name; - case Semicolon: return lastName; + case Semicolon: + return lastName; default: } token = token.getFirstChild(); @@ -143,9 +147,12 @@ class UnusedImportCheck extends Check { var name:String = ident.toString(); if (!checkName(typeName, moduleName, name)) continue; switch (ident.parent.tok) { - case Kwd(KwdClass), Kwd(KwdInterface), Kwd(KwdAbstract), Kwd(KwdEnum), Kwd(KwdTypedef): continue; - case Dot: continue; - default: return; + case Kwd(KwdClass), Kwd(KwdInterface), Kwd(KwdAbstract), Kwd(KwdEnum), Kwd(KwdTypedef): + continue; + case Dot: + continue; + default: + return; } } for (literal in stringLiterals) { @@ -194,13 +201,15 @@ class UnusedImportCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } diff --git a/src/checkstyle/checks/literal/ArrayLiteralCheck.hx b/src/checkstyle/checks/literal/ArrayLiteralCheck.hx index 17758587..aa455a81 100644 --- a/src/checkstyle/checks/literal/ArrayLiteralCheck.hx +++ b/src/checkstyle/checks/literal/ArrayLiteralCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.literal; /** Checks if the array is instantiated using [] which is shorter and cleaner, not with new. - **/ +**/ @name("ArrayLiteral", "ArrayInstantiation") @desc("Checks if the array is instantiated using [] which is shorter and cleaner, not with new.") class ArrayLiteralCheck extends Check { - public function new() { super(AST); categories = [Category.STYLE, Category.CLARITY]; @@ -14,8 +13,8 @@ class ArrayLiteralCheck extends Check { override function actualRun() { checker.ast.walkFile(function(e:Expr) { - switch (e.expr){ - case ENew({pack:[], name:"Array"}, _): + switch (e.expr) { + case ENew({pack: [], name: "Array"}, _): logPos('Bad array instantiation, use the array literal notation "[]" which is shorter and cleaner', e.pos); default: } diff --git a/src/checkstyle/checks/literal/ERegLiteralCheck.hx b/src/checkstyle/checks/literal/ERegLiteralCheck.hx index ff2e7f1b..e5125fd6 100644 --- a/src/checkstyle/checks/literal/ERegLiteralCheck.hx +++ b/src/checkstyle/checks/literal/ERegLiteralCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.literal; /** Checks for usage of EReg literals (between ~/ and /) instead of new. - **/ +**/ @name("ERegLiteral", "ERegInstantiation") @desc("Checks for usage of EReg literals (between ~/ and /) instead of new.") class ERegLiteralCheck extends Check { - public function new() { super(AST); categories = [Category.STYLE, Category.CLARITY]; @@ -15,11 +14,8 @@ class ERegLiteralCheck extends Check { override function actualRun() { checker.ast.walkFile(function(e:Expr) { if (isPosSuppressed(e.pos)) return; - switch (e.expr){ - case ENew( - {pack:[], name:"EReg"}, - [{expr:EConst(CString(re)), pos:_}, {expr:EConst(CString(opt)), pos:_}] - ): + switch (e.expr) { + case ENew({pack: [], name: "EReg"}, [{expr: EConst(CString(re)), pos: _}, {expr: EConst(CString(opt)), pos: _}]): if (~/\$\{.+\}/.match(re)) return; logPos('Bad EReg instantiation, define expression between "~/" and "/"', e.pos); default: diff --git a/src/checkstyle/checks/literal/HexadecimalLiteralCheck.hx b/src/checkstyle/checks/literal/HexadecimalLiteralCheck.hx index f7e4ea48..629e5d81 100644 --- a/src/checkstyle/checks/literal/HexadecimalLiteralCheck.hx +++ b/src/checkstyle/checks/literal/HexadecimalLiteralCheck.hx @@ -2,16 +2,15 @@ package checkstyle.checks.literal; /** Checks the letter case of hexadecimal literals. - **/ +**/ @name("HexadecimalLiteral", "HexadecimalLiterals") @desc("Checks the letter case of hexadecimal literals.") class HexadecimalLiteralCheck extends Check { - /** - policy for hexadecimal literals - - upperCase = use uppercase for all letters - - lowerCase = use lowercase for all letters - **/ + policy for hexadecimal literals + - upperCase = use uppercase for all letters + - lowerCase = use lowercase for all letters + **/ public var option:HexadecimalLiteralPolicy; public function new() { @@ -23,8 +22,9 @@ class HexadecimalLiteralCheck extends Check { override function actualRun() { checker.ast.walkFile(function(e:Expr) { - switch (e.expr){ - case EConst(CInt(s)): checkString(s, e.pos); + switch (e.expr) { + case EConst(CInt(s)): + checkString(s, e.pos); default: } }); @@ -43,10 +43,10 @@ class HexadecimalLiteralCheck extends Check { } /** - policy for hexadecimal literals - - upperCase = use uppercase for all letters - - lowerCase = use lowercase for all letters - **/ + policy for hexadecimal literals + - upperCase = use uppercase for all letters + - lowerCase = use lowercase for all letters +**/ @:enum abstract HexadecimalLiteralPolicy(String) { var UPPER_CASE = "upperCase"; diff --git a/src/checkstyle/checks/literal/MultipleStringLiteralsCheck.hx b/src/checkstyle/checks/literal/MultipleStringLiteralsCheck.hx index 48f1910c..2748e8ff 100644 --- a/src/checkstyle/checks/literal/MultipleStringLiteralsCheck.hx +++ b/src/checkstyle/checks/literal/MultipleStringLiteralsCheck.hx @@ -5,24 +5,23 @@ import checkstyle.utils.StringUtils; /** Checks for multiple occurrences of the same string literal within a single file. Code duplication makes maintenance more difficult, so it's better to replace the multiple occurrences with a constant. - **/ +**/ @name("MultipleStringLiterals") @desc("Checks for multiple occurrences of the same string literal within a single file. Code duplication makes maintenance more difficult, so it's better to replace the multiple occurrences with a constant.") class MultipleStringLiteralsCheck extends Check { - /** number of occurrences to allow - **/ + **/ public var allowDuplicates:Int; /** string literals must be "minLength" or more characters before including them - **/ + **/ public var minLength:Int; /** ignore string literals matching regex - **/ + **/ public var ignore:String; var ignoreRE:EReg; @@ -37,7 +36,7 @@ class MultipleStringLiteralsCheck extends Check { } override function actualRun() { - ignoreRE = new EReg (ignore, ""); + ignoreRE = new EReg(ignore, ""); var root:TokenTree = checker.getTokenTree(); var allLiterals:Map = new Map(); diff --git a/src/checkstyle/checks/literal/StringLiteralCheck.hx b/src/checkstyle/checks/literal/StringLiteralCheck.hx index 14548035..1601ec16 100644 --- a/src/checkstyle/checks/literal/StringLiteralCheck.hx +++ b/src/checkstyle/checks/literal/StringLiteralCheck.hx @@ -4,23 +4,22 @@ import checkstyle.utils.StringUtils; /** Checks for single or double quote string literals. - **/ +**/ @name("StringLiteral") @desc("Checks for single or double quote string literals.") class StringLiteralCheck extends Check { - /** policy for string literal use - onlySingle = enforce single quotes - onlyDouble = enforce double quotes, no interpolation allowed - doubleAndInterpolation = enforce double quotes, allow single quotes for interpolation - **/ + **/ public var policy:StringLiteralPolicy; /** "allowException" allows using single quotes in "onlyDouble" and "doubleAndInterpolation" mode, when string contains a double quote character. Or double quotes in "onlySingle" mode when string contains a single quote character, reducing the need to escape quotation marks. - **/ + **/ public var allowException:Bool; public function new() { @@ -72,17 +71,21 @@ class StringLiteralCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "policy", - values: [DOUBLE_AND_INTERPOLATION, ONLY_SINGLE, ONLY_DOUBLE] - }, + return [ { - propertyName: "allowException", - values: [false, true] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "policy", + values: [DOUBLE_AND_INTERPOLATION, ONLY_SINGLE, ONLY_DOUBLE] + }, + { + propertyName: "allowException", + values: [false, true] + } + ] + } + ]; } } diff --git a/src/checkstyle/checks/meta/RedundantAccessMetaBase.hx b/src/checkstyle/checks/meta/RedundantAccessMetaBase.hx index b7b3e215..9b6b0038 100644 --- a/src/checkstyle/checks/meta/RedundantAccessMetaBase.hx +++ b/src/checkstyle/checks/meta/RedundantAccessMetaBase.hx @@ -2,15 +2,14 @@ package checkstyle.checks.meta; /** Checks for redundant @:allow metadata - **/ +**/ @ignore("Base class for name checks") class RedundantAccessMetaBase extends Check { - /** switches behaviour of check to - false = look for redundant access modifications - true = to discourage its use everywhere - **/ + **/ public var prohibitMeta:Bool; var metaName:String; @@ -30,10 +29,14 @@ class RedundantAccessMetaBase extends Check { for (token in docTokens) { if (isPosSuppressed(token.pos)) continue; var target:TokenTree = TokenTreeAccessHelper.access(token) - .firstChild().is(DblDot) - .firstChild().is(Const(CIdent(metaName))) - .firstChild().is(POpen) - .firstChild().token; + .firstChild() + .is(DblDot) + .firstChild() + .is(Const(CIdent(metaName))) + .firstChild() + .is(POpen) + .firstChild() + .token; if (target == null) continue; if (prohibitMeta) { @@ -43,10 +46,10 @@ class RedundantAccessMetaBase extends Check { var parent:TokenTree = token.parent; if (parent == null) continue; var info:RedundantAccessMetaInfo = { - name:getTargetName(target), - ident:parent.toString(), - token:token, - pos:parent.getPos() + name: getTargetName(target), + ident: parent.toString(), + token: token, + pos: parent.getPos() }; if (filerParent(parent, info)) continue; checkAndAdd(infos, info); @@ -82,12 +85,14 @@ class RedundantAccessMetaBase extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/meta/RedundantAccessMetaCheck.hx b/src/checkstyle/checks/meta/RedundantAccessMetaCheck.hx index 980601d5..fa91d402 100644 --- a/src/checkstyle/checks/meta/RedundantAccessMetaCheck.hx +++ b/src/checkstyle/checks/meta/RedundantAccessMetaCheck.hx @@ -2,7 +2,7 @@ package checkstyle.checks.meta; /** Checks for redundant @:access metadata - **/ +**/ @name("RedundantAccessMeta") @desc("Checks for redundant @:access metadata") class RedundantAccessMetaCheck extends RedundantAccessMetaBase { diff --git a/src/checkstyle/checks/meta/RedundantAllowMetaCheck.hx b/src/checkstyle/checks/meta/RedundantAllowMetaCheck.hx index be5ee8fd..49a0221b 100644 --- a/src/checkstyle/checks/meta/RedundantAllowMetaCheck.hx +++ b/src/checkstyle/checks/meta/RedundantAllowMetaCheck.hx @@ -2,7 +2,7 @@ package checkstyle.checks.meta; /** Checks for redundant @:allow metadata - **/ +**/ @name("RedundantAllowMeta") @desc("Checks for redundant @:allow metadata") class RedundantAllowMetaCheck extends RedundantAccessMetaBase { diff --git a/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx b/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx index 9941282e..8192008a 100644 --- a/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx +++ b/src/checkstyle/checks/metrics/CyclomaticComplexityCheck.hx @@ -4,24 +4,23 @@ using Lambda; /** Checks the complexity of methods using McCabe simplified cyclomatic complexity check. Complexity levels can be customised using "thresholds" property. - **/ +**/ @name("CyclomaticComplexity") @desc("Checks the complexity of methods using McCabe simplified cyclomatic complexity check. Complexity levels can be customised using `thresholds` property.") class CyclomaticComplexityCheck extends Check { - static var DEFAULT_COMPLEXITY_WARNING:Int = 20; static var DEFAULT_COMPLEXITY_ERROR:Int = 25; /** list of thresholds that define which severity level to report when complexity of method is above its limit - **/ + **/ public var thresholds:Array; public function new() { super(AST); thresholds = [ - { severity : WARNING, complexity : DEFAULT_COMPLEXITY_WARNING }, - { severity : ERROR, complexity : DEFAULT_COMPLEXITY_ERROR } + {severity: WARNING, complexity: DEFAULT_COMPLEXITY_WARNING}, + {severity: ERROR, complexity: DEFAULT_COMPLEXITY_ERROR} ]; categories = [Category.COMPLEXITY]; points = 13; @@ -31,7 +30,7 @@ class CyclomaticComplexityCheck extends Check { forEachField(function(field, _) { switch (field.kind) { case FieldType.FFun(f): - calculateComplexity({ name:field.name, expr:f.expr, pos:field.pos}); + calculateComplexity({name: field.name, expr: f.expr, pos: field.pos}); default: } }); @@ -53,42 +52,53 @@ class CyclomaticComplexityCheck extends Check { function evaluateExpr(e:Expr):Int { if (e == null || e.expr == null) return 0; return switch (e.expr) { - case ExprDef.EArray(e1, e2) : evaluateExpr(e1) + evaluateExpr(e2); - case ExprDef.EBinop(op, e1, e2) : evaluateExpr(e1) + evaluateExpr(e2) + switch (op) { - case haxe.macro.Expr.Binop.OpBoolAnd : 1; - case haxe.macro.Expr.Binop.OpBoolOr : 1; - default : 0; + case ExprDef.EArray(e1, e2): evaluateExpr(e1) + evaluateExpr(e2); + case ExprDef.EBinop(op, e1, e2): + evaluateExpr(e1) + evaluateExpr(e2) + switch (op) { + case haxe.macro.Expr.Binop.OpBoolAnd: 1; + case haxe.macro.Expr.Binop.OpBoolOr: 1; + default: 0; }; - case ExprDef.EParenthesis(e) : evaluateExpr(e); - case ExprDef.EObjectDecl(fields) : + case ExprDef.EParenthesis(e): evaluateExpr(e); + case ExprDef.EObjectDecl(fields): fields.map(function(f):Expr { return f.expr; - }).fold(function(e:Expr, total:Int):Int { return total + evaluateExpr(e); }, 0); - case ExprDef.EArrayDecl(values) : - values.fold(function(e:Expr, total:Int):Int { return total + evaluateExpr(e); }, 0); - case ExprDef.EBlock(exprs) : - exprs.fold(function(e:Expr, total:Int):Int { return total + evaluateExpr(e); }, 0); - case ExprDef.EFor(it, e) : 1 + evaluateExpr(it) + evaluateExpr(e); + }).fold(function(e:Expr, total:Int):Int { + return total + evaluateExpr(e); + }, 0); + case ExprDef.EArrayDecl(values): + values.fold(function(e:Expr, total:Int):Int { + return total + evaluateExpr(e); + }, 0); + case ExprDef.EBlock(exprs): + exprs.fold(function(e:Expr, total:Int):Int { + return total + evaluateExpr(e); + }, 0); + case ExprDef.EFor(it, e): 1 + evaluateExpr(it) + evaluateExpr(e); #if (haxe_ver < 4.0) - case ExprDef.EIn(e1, e2) : evaluateExpr(e1) + evaluateExpr(e2); + case ExprDef.EIn(e1, e2): evaluateExpr(e1) + evaluateExpr(e2); #end - case ExprDef.EIf(econd, eif, eelse) : 1 + evaluateExpr(econd) + evaluateExpr(eif) + evaluateExpr(eelse); - case ExprDef.EWhile(econd, e, _) : 1 + evaluateExpr(econd) + evaluateExpr(e); - case ExprDef.ESwitch(e, cases, def) : + case ExprDef.EIf(econd, eif, eelse): 1 + evaluateExpr(econd) + evaluateExpr(eif) + evaluateExpr(eelse); + case ExprDef.EWhile(econd, e, _): 1 + evaluateExpr(econd) + evaluateExpr(e); + case ExprDef.ESwitch(e, cases, def): evaluateExpr(def) + cases.map(function(c:Case):Expr { return c.expr; - }).fold(function(e:Expr, total:Int):Int { return total + 1 + evaluateExpr(e); }, 0); - case ExprDef.ETry(e, catches) : + }).fold(function(e:Expr, total:Int):Int { + return total + 1 + evaluateExpr(e); + }, 0); + case ExprDef.ETry(e, catches): catches.map(function(c:Catch):Expr { return c.expr; - }).fold(function(e:Expr, total:Int):Int { return total + 1 + evaluateExpr(e); }, 0); - case ExprDef.EReturn(e) : (e != null) ? evaluateExpr(e) : 0; - case ExprDef.EUntyped(e) : evaluateExpr(e); - case ExprDef.EThrow(e) : evaluateExpr(e); - case ExprDef.ECast(e, _) : evaluateExpr(e); - case ExprDef.EDisplay(e, _) : evaluateExpr(e); - case ExprDef.ETernary(econd, eif, eelse) : 1 + evaluateExpr(econd) + evaluateExpr(eif) + evaluateExpr(eelse); - case ExprDef.ECheckType(e, _) : evaluateExpr(e); + }).fold(function(e:Expr, total:Int):Int { + return total + 1 + evaluateExpr(e); + }, 0); + case ExprDef.EReturn(e): (e != null) ? evaluateExpr(e) : 0; + case ExprDef.EUntyped(e): evaluateExpr(e); + case ExprDef.EThrow(e): evaluateExpr(e); + case ExprDef.ECast(e, _): evaluateExpr(e); + case ExprDef.EDisplay(e, _): evaluateExpr(e); + case ExprDef.ETernary(econd, eif, eelse): 1 + evaluateExpr(econd) + evaluateExpr(eif) + evaluateExpr(eelse); + case ExprDef.ECheckType(e, _): evaluateExpr(e); default: 0; } } @@ -98,28 +108,22 @@ class CyclomaticComplexityCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "thresholds", - values: [[ - { severity : WARNING, complexity : 6 }, - { severity : ERROR, complexity : 16 } - ], - [ - { severity : WARNING, complexity : 11 }, - { severity : ERROR, complexity : 21 } - ], - [ - { severity : WARNING, complexity : 16 }, - { severity : ERROR, complexity : 26 } - ], - [ - { severity : WARNING, complexity : 21 }, - { severity : ERROR, complexity : 31 } - ]] - }] - }]; + return [ + { + fixed: [], + properties: [ + { + propertyName: "thresholds", + values: [ + [{severity: WARNING, complexity: 6}, {severity: ERROR, complexity: 16}], + [{severity: WARNING, complexity: 11}, {severity: ERROR, complexity: 21}], + [{severity: WARNING, complexity: 16}, {severity: ERROR, complexity: 26}], + [{severity: WARNING, complexity: 21}, {severity: ERROR, complexity: 31}] + ] + } + ] + } + ]; } } @@ -131,11 +135,12 @@ typedef Target = { /** threshold for code complexity - **/ +**/ typedef Threshold = { var severity:SeverityLevel; + /** complexity value associated with "severity" - **/ + **/ var complexity:Int; } \ No newline at end of file diff --git a/src/checkstyle/checks/modifier/ModifierOrderCheck.hx b/src/checkstyle/checks/modifier/ModifierOrderCheck.hx index 66350242..c72e069e 100644 --- a/src/checkstyle/checks/modifier/ModifierOrderCheck.hx +++ b/src/checkstyle/checks/modifier/ModifierOrderCheck.hx @@ -4,26 +4,18 @@ import haxe.macro.PositionTools; /** Checks that the order of modifiers conforms to the standards. - **/ +**/ @name("ModifierOrder", "AccessOrder") @desc("Checks that the order of modifiers conforms to the standards.") class ModifierOrderCheck extends Check { - /** order in which modifier should occur - **/ + **/ public var modifiers:Array; public function new() { super(AST); - modifiers = [ - MACRO, - OVERRIDE, - PUBLIC_PRIVATE, - STATIC, - INLINE, - DYNAMIC - ]; + modifiers = [MACRO, OVERRIDE, PUBLIC_PRIVATE, STATIC, INLINE, DYNAMIC]; categories = [Category.STYLE, Category.CLARITY]; } @@ -74,7 +66,7 @@ class ModifierOrderCheck extends Check { - DYNAMIC = dynamic modifier - EXTERN = extern modifier - FINAL = final modifier - **/ +**/ @:enum abstract ModifierOrderCheckModifier(String) { var PUBLIC_PRIVATE = "PUBLIC_PRIVATE"; @@ -91,23 +83,15 @@ abstract ModifierOrderCheckModifier(String) { @:from public static function fromAccess(access:Access):ModifierOrderCheckModifier { return switch (access) { - case APublic, APrivate: - PUBLIC_PRIVATE; - case AStatic: - STATIC; - case AInline: - INLINE; - case AOverride: - OVERRIDE; - case AMacro: - MACRO; - case ADynamic: - DYNAMIC; + case APublic, APrivate: PUBLIC_PRIVATE; + case AStatic: STATIC; + case AInline: INLINE; + case AOverride: OVERRIDE; + case AMacro: MACRO; + case ADynamic: DYNAMIC; #if (haxe_ver >= 4.0) - case AExtern: - EXTERN; - case AFinal: - FINAL; + case AExtern: EXTERN; + case AFinal: FINAL; #end } } diff --git a/src/checkstyle/checks/modifier/PublicAccessorCheck.hx b/src/checkstyle/checks/modifier/PublicAccessorCheck.hx index 99248603..5ca10384 100644 --- a/src/checkstyle/checks/modifier/PublicAccessorCheck.hx +++ b/src/checkstyle/checks/modifier/PublicAccessorCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.modifier; /** Checks for public accessors. - **/ +**/ @name("PublicAccessor") @desc("Checks for public accessors.") class PublicAccessorCheck extends Check { - public function new() { super(AST); categories = [Category.STYLE, Category.CLARITY]; diff --git a/src/checkstyle/checks/modifier/RedundantModifierCheck.hx b/src/checkstyle/checks/modifier/RedundantModifierCheck.hx index 6a63b6fe..be7ec1b3 100644 --- a/src/checkstyle/checks/modifier/RedundantModifierCheck.hx +++ b/src/checkstyle/checks/modifier/RedundantModifierCheck.hx @@ -3,25 +3,24 @@ package checkstyle.checks.modifier; /** Checks for redundant modifiers. Omitting the visibility modifier usually defaults the visibility to "private" in normal classes and "public" in interfaces and externs. - **/ +**/ @name("RedundantModifier", "PublicPrivate") @desc("Checks for redundant modifiers.") class RedundantModifierCheck extends Check { - /** enforce use of "public" and "private" modifiers implies enforcePublic and enforcePrivate - **/ + **/ public var enforcePublicPrivate:Bool; /** enforce use of "public" modifiers - **/ + **/ public var enforcePublic:Bool; /** enforce use of "private" modifiers - **/ + **/ public var enforcePrivate:Bool; public function new() { @@ -62,21 +61,25 @@ class RedundantModifierCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "enforcePrivate", - values: [true, false] - }, - { - propertyName: "enforcePublic", - values: [true, false] - }, + return [ { - propertyName: "enforcePublicPrivate", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "enforcePrivate", + values: [true, false] + }, + { + propertyName: "enforcePublic", + values: [true, false] + }, + { + propertyName: "enforcePublicPrivate", + values: [true, false] + } + ] + } + ]; } } diff --git a/src/checkstyle/checks/naming/CatchParameterNameCheck.hx b/src/checkstyle/checks/naming/CatchParameterNameCheck.hx index e1d407cf..3f2b3b85 100644 --- a/src/checkstyle/checks/naming/CatchParameterNameCheck.hx +++ b/src/checkstyle/checks/naming/CatchParameterNameCheck.hx @@ -2,14 +2,13 @@ package checkstyle.checks.naming; /** Checks that catch parameter names conform to a format specified by the "format" property. - **/ +**/ @name("CatchParameterName") @desc("Checks that catch parameter names conform to a format specified by the `format` property.") class CatchParameterNameCheck extends Check { - /** regex name format - **/ + **/ public var format:String; public function new() { diff --git a/src/checkstyle/checks/naming/ConstantNameCheck.hx b/src/checkstyle/checks/naming/ConstantNameCheck.hx index 78673f7d..433bf085 100644 --- a/src/checkstyle/checks/naming/ConstantNameCheck.hx +++ b/src/checkstyle/checks/naming/ConstantNameCheck.hx @@ -4,11 +4,10 @@ import checkstyle.detect.DetectableInstance; /** Checks that the constants (static / static inline with initialisation) conform to a format specified by the "format" property. - **/ +**/ @name("ConstantName") @desc("Checks that the constants (static / static inline with initialisation) conform to a format specified by the `format` property.") class ConstantNameCheck extends NameCheckBase { - public function new() { super(); format = UPPER_CASE; @@ -52,28 +51,32 @@ class ConstantNameCheck extends NameCheckBase { propertyName: "tokens", value: [INLINE] }], - properties: [{ - propertyName: "format", - values: [UPPER_CASE, CAMEL_CASE, LOWER_CASE] - }, - { - propertyName: "ignoreExtern", - values: [true, false] - }] + properties: [ + { + propertyName: "format", + values: [UPPER_CASE, CAMEL_CASE, LOWER_CASE] + }, + { + propertyName: "ignoreExtern", + values: [true, false] + } + ] }; var instanceNotInline:DetectableInstance = { fixed: [{ propertyName: "tokens", value: [NOTINLINE] }], - properties: [{ - propertyName: "format", - values: [UPPER_CASE, CAMEL_CASE, LOWER_CASE] - }, - { - propertyName: "ignoreExtern", - values: [true, false] - }] + properties: [ + { + propertyName: "format", + values: [UPPER_CASE, CAMEL_CASE, LOWER_CASE] + }, + { + propertyName: "ignoreExtern", + values: [true, false] + } + ] } return [instanceInline, instanceNotInline]; } @@ -83,7 +86,7 @@ class ConstantNameCheck extends NameCheckBase { supports inline and non inline constants - INLINE = "static inline var" - NOTINLINE = "static var" - **/ +**/ @:enum abstract ConstantNameCheckToken(String) { var INLINE = "INLINE"; diff --git a/src/checkstyle/checks/naming/ListenerNameCheck.hx b/src/checkstyle/checks/naming/ListenerNameCheck.hx index 3a40c15e..75ccd60d 100644 --- a/src/checkstyle/checks/naming/ListenerNameCheck.hx +++ b/src/checkstyle/checks/naming/ListenerNameCheck.hx @@ -2,19 +2,18 @@ package checkstyle.checks.naming; /** Checks the naming conventions of event listener functions specified using "listeners" property. - **/ +**/ @name("ListenerName") @desc("Checks the naming conventions of event listener functions specified using `listeners` property.") class ListenerNameCheck extends Check { - /** list of function names used to register listeners - **/ + **/ public var listeners:Array; /** regex name format - **/ + **/ public var format:String; var formatRE:EReg; @@ -28,7 +27,7 @@ class ListenerNameCheck extends Check { override public function actualRun() { checker.ast.walkFile(function(e) { if (isPosSuppressed(e.pos)) return; - switch (e.expr){ + switch (e.expr) { case ECall(e, params): searchCall(e, params); default: @@ -41,17 +40,20 @@ class ListenerNameCheck extends Check { } function searchLeftCall(e, name):Bool { - switch (e.expr){ - case EConst(CIdent(ident)): return ident == name; - case EField(e2, field): return field == name; - default:return false; + switch (e.expr) { + case EConst(CIdent(ident)): + return ident == name; + case EField(e2, field): + return field == name; + default: + return false; } } function searchCallParam(p:Array) { if (p.length < 2) return; var listener = p[1]; - switch (listener.expr){ + switch (listener.expr) { case EConst(CIdent(ident)): checkListenerName(ident, listener.pos); default: @@ -59,7 +61,7 @@ class ListenerNameCheck extends Check { } function checkListenerName(name:String, pos:Position) { - formatRE = new EReg (format, ""); + formatRE = new EReg(format, ""); var match = formatRE.match(name); if (!match) logPos('Wrong listener name: "${name}" (should be "~/${format}/")', pos); } diff --git a/src/checkstyle/checks/naming/LocalVariableNameCheck.hx b/src/checkstyle/checks/naming/LocalVariableNameCheck.hx index b764058e..f0cfcd95 100644 --- a/src/checkstyle/checks/naming/LocalVariableNameCheck.hx +++ b/src/checkstyle/checks/naming/LocalVariableNameCheck.hx @@ -2,18 +2,17 @@ package checkstyle.checks.naming; /** Checks that the local variable names conform to a format specified by the "format" property. - **/ +**/ @name("LocalVariableName") @desc("Checks that the local variable names conform to a format specified by the `format` property.") class LocalVariableNameCheck extends NameCheckBase { - public function new() { super(); format = "^[a-z][a-zA-Z0-9]*$"; } override function actualRun() { - formatRE = new EReg (format, ""); + formatRE = new EReg(format, ""); checker.ast.walkFile(function(e) { switch (e.expr) { case EVars(vars): diff --git a/src/checkstyle/checks/naming/MemberNameCheck.hx b/src/checkstyle/checks/naming/MemberNameCheck.hx index 3e652f29..9d31c7b6 100644 --- a/src/checkstyle/checks/naming/MemberNameCheck.hx +++ b/src/checkstyle/checks/naming/MemberNameCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.naming; /** Checks that instance variable names conform to a format specified by the "format" property. - **/ +**/ @name("MemberName") @desc("Checks that instance variable names conform to a format specified by the `format` property.") class MemberNameCheck extends NameCheckBase { - public function new() { super(); format = "^[a-z][a-zA-Z0-9]*$"; @@ -101,7 +100,7 @@ class MemberNameCheck extends NameCheckBase { - CLASS = all class fields, use in combination with PUBLIC and PRIVATE to only match public/private class fields - ABSTRACT = all abstract fields, use in combination with PUBLIC and PRIVATE to only match public/private abstract fields - TYPEDEF = all typedef fields - **/ +**/ @:enum abstract MemberNameCheckToken(String) { var PUBLIC = "PUBLIC"; diff --git a/src/checkstyle/checks/naming/MethodNameCheck.hx b/src/checkstyle/checks/naming/MethodNameCheck.hx index 9cc5de3c..fb0e03fa 100644 --- a/src/checkstyle/checks/naming/MethodNameCheck.hx +++ b/src/checkstyle/checks/naming/MethodNameCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.naming; /** Checks that method names conform to a format specified by the "format" property. - **/ +**/ @name("MethodName") @desc("Checks that method names conform to a format specified by the `format` property.") class MethodNameCheck extends NameCheckBase { - public function new() { super(); format = "^[a-z][a-zA-Z0-9]*$"; @@ -65,7 +64,7 @@ class MethodNameCheck extends NameCheckBase { - NOTSTATIC = all non static methods - INLINE = all inline methods - NOTINLINE = all non-inline methods - **/ +**/ @:enum abstract MethodNameCheckToken(String) { var PUBLIC = "PUBLIC"; diff --git a/src/checkstyle/checks/naming/NameCheckBase.hx b/src/checkstyle/checks/naming/NameCheckBase.hx index 70787fd2..44ae5d8c 100644 --- a/src/checkstyle/checks/naming/NameCheckBase.hx +++ b/src/checkstyle/checks/naming/NameCheckBase.hx @@ -2,23 +2,22 @@ package checkstyle.checks.naming; /** Base class for name checks - **/ +**/ @ignore("Base class for name checks") class NameCheckBase extends Check { - /** regex name format - **/ + **/ public var format:String; /** list of tokens to limit where names should conform to "format" - **/ + **/ public var tokens:Array; /** ignores names inside extern types - **/ + **/ public var ignoreExtern:Bool; var formatRE:EReg; @@ -36,7 +35,7 @@ class NameCheckBase extends Check { } override function actualRun() { - formatRE = new EReg (format, ""); + formatRE = new EReg(format, ""); checkClassFields(); } diff --git a/src/checkstyle/checks/naming/ParameterNameCheck.hx b/src/checkstyle/checks/naming/ParameterNameCheck.hx index 096129fe..43851530 100644 --- a/src/checkstyle/checks/naming/ParameterNameCheck.hx +++ b/src/checkstyle/checks/naming/ParameterNameCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.naming; /** Checks that parameter names conform to a format specified by the "format" property. - **/ +**/ @name("ParameterName") @desc("Checks that parameter names conform to a format specified by the `format` property.") class ParameterNameCheck extends NameCheckBase { - public function new() { super(); format = "^(_|[a-z][a-zA-Z0-9]*$)"; diff --git a/src/checkstyle/checks/naming/TypeNameCheck.hx b/src/checkstyle/checks/naming/TypeNameCheck.hx index 834c7314..b964a1f5 100644 --- a/src/checkstyle/checks/naming/TypeNameCheck.hx +++ b/src/checkstyle/checks/naming/TypeNameCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.naming; /** Checks that type names conform to a format specified by the "format" property. - **/ +**/ @name("TypeName") @desc("Checks that type names conform to a format specified by the `format` property.") class TypeNameCheck extends NameCheckBase { - public function new() { super(); format = "^[A-Z]+[a-zA-Z0-9]*$"; @@ -54,7 +53,7 @@ class TypeNameCheck extends NameCheckBase { - ENUM = all enum types - ABSTRACT = all abstract types - TYPEDEF = all typedef types - **/ +**/ @:enum abstract TypeNameCheckToken(String) { var INTERFACE = "INTERFACE"; diff --git a/src/checkstyle/checks/size/FileLengthCheck.hx b/src/checkstyle/checks/size/FileLengthCheck.hx index 3c3fc5e3..a40155a9 100644 --- a/src/checkstyle/checks/size/FileLengthCheck.hx +++ b/src/checkstyle/checks/size/FileLengthCheck.hx @@ -3,16 +3,15 @@ package checkstyle.checks.size; /** Checks for long source files. If a source file becomes very long it is hard to understand. Therefore long classes should usually be refactored into several individual classes that focus on a specific task. - **/ +**/ @name("FileLength") @desc("Checks for long source files. If a source file becomes very long it is hard to understand. Therefore long classes should usually be refactored into several individual classes that focus on a specific task.") class FileLengthCheck extends Check { - static var DEFAULT_MAX_LENGTH:Int = 2000; /** maximum number of lines permitted per file (default: 2000) - **/ + **/ public var max:Int; public function new() { @@ -24,8 +23,9 @@ class FileLengthCheck extends Check { override function actualRun() { for (td in checker.ast.decls) { - switch (td.decl){ - case EClass(d): for (field in d.data) if (isCheckSuppressed(field)) return; + switch (td.decl) { + case EClass(d): + for (field in d.data) if (isCheckSuppressed(field)) return; default: } } @@ -35,12 +35,14 @@ class FileLengthCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "max", - values: [for (i in 0...10) 400 + i * 200] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "max", + values: [for (i in 0...10) 400 + i * 200] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/size/LineLengthCheck.hx b/src/checkstyle/checks/size/LineLengthCheck.hx index d8f777a0..e41deda1 100644 --- a/src/checkstyle/checks/size/LineLengthCheck.hx +++ b/src/checkstyle/checks/size/LineLengthCheck.hx @@ -2,21 +2,20 @@ package checkstyle.checks.size; /** Checks for long lines. Long lines are hard to read. - **/ +**/ @name("LineLength") @desc("Checks for long lines. Long lines are hard to read.") class LineLengthCheck extends Check { - static var DEFAULT_MAX_LENGTH:Int = 160; /** maximum number of characters per line (default: 160) - **/ + **/ public var max:Int; /** ignore lines matching regex - **/ + **/ public var ignorePattern:String; public function new() { @@ -39,12 +38,14 @@ class LineLengthCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "max", - values: [for (i in 0...7) 80 + i * 20] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "max", + values: [for (i in 0...7) 80 + i * 20] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/size/MethodCountCheck.hx b/src/checkstyle/checks/size/MethodCountCheck.hx index a36dede1..3c62e079 100644 --- a/src/checkstyle/checks/size/MethodCountCheck.hx +++ b/src/checkstyle/checks/size/MethodCountCheck.hx @@ -2,26 +2,25 @@ package checkstyle.checks.size; /** Checks the number of methods declared in each type. This includes the number of each scope (`private` and `public`) as well as an overall total. - **/ +**/ @name("MethodCount") @desc("Checks the number of methods declared in each type. This includes the number of each scope (`private` and `public`) as well as an overall total.") class MethodCountCheck extends Check { - static var DEFAULT_MAX_COUNT:Int = 100; /** maximum number of functions permitted per file (default: 100) - **/ + **/ public var maxTotal:Int; /** maximum number of private functions permitted per file (default: 100) - **/ + **/ public var maxPrivate:Int; /** maximum number of public functions permitted per file (default: 100) - **/ + **/ public var maxPublic:Int; public function new() { @@ -60,20 +59,24 @@ class MethodCountCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "maxTotal", - values: [for (i in 0...21) 10 + i * 5] - }, - { - propertyName: "maxPrivate", - values: [for (i in 0...21) 10 + i * 5] - }, + return [ { - propertyName: "maxPublic", - values: [for (i in 0...21) 10 + i * 5] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "maxTotal", + values: [for (i in 0...21) 10 + i * 5] + }, + { + propertyName: "maxPrivate", + values: [for (i in 0...21) 10 + i * 5] + }, + { + propertyName: "maxPublic", + values: [for (i in 0...21) 10 + i * 5] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/size/MethodLengthCheck.hx b/src/checkstyle/checks/size/MethodLengthCheck.hx index cb96f934..74246cc7 100755 --- a/src/checkstyle/checks/size/MethodLengthCheck.hx +++ b/src/checkstyle/checks/size/MethodLengthCheck.hx @@ -3,21 +3,20 @@ package checkstyle.checks.size; /** Checks for long methods. If a method becomes very long it is hard to understand. Therefore long methods should usually be refactored into several individual methods that focus on a specific task. - **/ +**/ @name("MethodLength") @desc("Checks for long methods. If a method becomes very long it is hard to understand. Therefore long methods should usually be refactored into several individual methods that focus on a specific task.") class MethodLengthCheck extends Check { - static var DEFAULT_MAX_LENGTH:Int = 50; /** maximum number of lines per method (default: 50) - **/ + **/ public var max:Int; /** maximum includes empty lines / should ignore empty lines - **/ + **/ public var countEmpty:Bool; public function new() { @@ -33,14 +32,14 @@ class MethodLengthCheck extends Check { } function searchField(f:Field, _) { - switch (f.kind){ + switch (f.kind) { case FFun(ff): checkMethod(f); default: } f.walkField(function(e) { - switch (e.expr){ + switch (e.expr) { case EFunction(name, ff): checkFunction(e); default: @@ -62,10 +61,11 @@ class MethodLengthCheck extends Check { var lmin = lp.line; var lmax = checker.getLinePos(f.pos.max).line; var fname = "(anonymous)"; - switch (f.expr){ + switch (f.expr) { case EFunction(name, ff): if (name != null) fname = name; - default: throw "EFunction only"; + default: + throw "EFunction only"; } var len = getLineCount(lmin, lmax); @@ -87,16 +87,20 @@ class MethodLengthCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "max", - values: [for (i in 0...17) 20 + i * 5] - }, + return [ { - propertyName: "countEmpty", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "max", + values: [for (i in 0...17) 20 + i * 5] + }, + { + propertyName: "countEmpty", + values: [true, false] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/size/ParameterNumberCheck.hx b/src/checkstyle/checks/size/ParameterNumberCheck.hx index f6c860e7..e8b093bc 100644 --- a/src/checkstyle/checks/size/ParameterNumberCheck.hx +++ b/src/checkstyle/checks/size/ParameterNumberCheck.hx @@ -2,21 +2,20 @@ package checkstyle.checks.size; /** Checks the number of parameters of a method. - **/ +**/ @name("ParameterNumber") @desc("Checks the number of parameters of a method.") class ParameterNumberCheck extends Check { - static var DEFAULT_MAX_PARAMS:Int = 7; /** maximum number of parameters per method (default: 7) - **/ + **/ public var max:Int; /** ignore methods with "override", only base class violates - **/ + **/ public var ignoreOverriddenMethods:Bool; public function new() { @@ -47,16 +46,20 @@ class ParameterNumberCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "max", - values: [for (i in 4...15) i] - }, + return [ { - propertyName: "ignoreOverriddenMethods", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "max", + values: [for (i in 4...15) i] + }, + { + propertyName: "ignoreOverriddenMethods", + values: [true, false] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/type/AnonymousCheck.hx b/src/checkstyle/checks/type/AnonymousCheck.hx index 79b274e8..fdddc9be 100644 --- a/src/checkstyle/checks/type/AnonymousCheck.hx +++ b/src/checkstyle/checks/type/AnonymousCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.type; /** Check to find any anonymous type structures used. - **/ +**/ @name("Anonymous") @desc("Check to find any anonymous type structures used.") class AnonymousCheck extends Check { - public function new() { super(AST); categories = [Category.STYLE, Category.CLARITY, Category.BUG_RISK, Category.COMPLEXITY]; @@ -29,13 +28,12 @@ class AnonymousCheck extends Check { function checkLocalVars() { checker.ast.walkFile(function(e) { - switch (e.expr){ + switch (e.expr) { case EVars(vars): for (v in vars) { if (v.type == null) continue; switch (v.type) { - case TAnonymous(fields): - error(v.name, e.pos); + case TAnonymous(fields): error(v.name, e.pos); default: } } @@ -49,12 +47,14 @@ class AnonymousCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/type/DynamicCheck.hx b/src/checkstyle/checks/type/DynamicCheck.hx index 2d8bb4a9..66062558 100644 --- a/src/checkstyle/checks/type/DynamicCheck.hx +++ b/src/checkstyle/checks/type/DynamicCheck.hx @@ -4,11 +4,10 @@ import checkstyle.utils.ComplexTypeUtils; /** Checks for use of Dynamic type anywhere in the code. - **/ +**/ @name("Dynamic") @desc("Checks for use of Dynamic type anywhere in the code.") class DynamicCheck extends Check { - public function new() { super(AST); categories = [Category.CLARITY, Category.BUG_RISK, Category.COMPLEXITY]; @@ -35,12 +34,14 @@ class DynamicCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/type/ReturnCheck.hx b/src/checkstyle/checks/type/ReturnCheck.hx index ea129bf6..6609e8cd 100644 --- a/src/checkstyle/checks/type/ReturnCheck.hx +++ b/src/checkstyle/checks/type/ReturnCheck.hx @@ -2,24 +2,23 @@ package checkstyle.checks.type; /** Warns if Void is used for return or if return type is not specified when returning. - **/ +**/ @name("Return") @desc("Warns if Void is used for return or if return type is not specified when returning.") class ReturnCheck extends Check { - /** allows empty return which is mostly used to exit functions. - **/ + **/ public var allowEmptyReturn:Bool; /** enforces return type for every function - **/ + **/ public var enforceReturnType:Bool; /** enforces return type for anonymous functions - **/ + **/ public var enforceReturnTypeForAnonymous:Bool; public function new() { @@ -130,20 +129,24 @@ class ReturnCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "allowEmptyReturn", - values: [true, false] - }, - { - propertyName: "enforceReturnTypeForAnonymous", - values: [true, false] - }, + return [ { - propertyName: "enforceReturnType", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "allowEmptyReturn", + values: [true, false] + }, + { + propertyName: "enforceReturnTypeForAnonymous", + values: [true, false] + }, + { + propertyName: "enforceReturnType", + values: [true, false] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/type/TypeCheck.hx b/src/checkstyle/checks/type/TypeCheck.hx index 478c137e..48e4015c 100644 --- a/src/checkstyle/checks/type/TypeCheck.hx +++ b/src/checkstyle/checks/type/TypeCheck.hx @@ -2,14 +2,13 @@ package checkstyle.checks.type; /** Checks if type is specified or not for member variables. - **/ +**/ @name("Type") @desc("Checks if type is specified or not for member variables.") class TypeCheck extends Check { - /** ignores fields inside abstract enums - **/ + **/ public var ignoreEnumAbstractValues:Bool; public function new() { @@ -35,12 +34,14 @@ class TypeCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "severity", - values: [SeverityLevel.INFO] - }] - }]; + return [ + { + fixed: [], + properties: [{ + propertyName: "severity", + values: [SeverityLevel.INFO] + }] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/ArrayAccessCheck.hx b/src/checkstyle/checks/whitespace/ArrayAccessCheck.hx index 64206066..4a9899c9 100644 --- a/src/checkstyle/checks/whitespace/ArrayAccessCheck.hx +++ b/src/checkstyle/checks/whitespace/ArrayAccessCheck.hx @@ -2,19 +2,18 @@ package checkstyle.checks.whitespace; /** Checks for spaces before array access or inside array elements. Finds code like "a [0], a[ 0]", etc. - **/ +**/ @name("ArrayAccess") @desc("Checks for spaces before array access or inside array elements. Finds code like `a [0], a[ 0]`, etc.") class ArrayAccessCheck extends Check { - /** set "spaceBefore" to false to detect space between array and "[" - **/ + **/ public var spaceBefore:Bool; /** set to false to detect space between brackets ("[" + "]") and index - **/ + **/ public var spaceInside:Bool; public function new() { @@ -53,16 +52,20 @@ class ArrayAccessCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "spaceBefore", - values: [true, false] - }, + return [ { - propertyName: "spaceInside", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "spaceBefore", + values: [true, false] + }, + { + propertyName: "spaceInside", + values: [true, false] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/EmptyLinesCheck.hx b/src/checkstyle/checks/whitespace/EmptyLinesCheck.hx index 9a9d5a20..d2be4942 100644 --- a/src/checkstyle/checks/whitespace/EmptyLinesCheck.hx +++ b/src/checkstyle/checks/whitespace/EmptyLinesCheck.hx @@ -3,44 +3,43 @@ package checkstyle.checks.whitespace; /** Checks for consecutive empty lines (default is 1). Also have options to check empty line separators after package, single-line and multi-line comments and class/interface/abstract declarations. - **/ +**/ @name("EmptyLines") @desc("Checks for consecutive empty lines (default is 1). Also have options to check empty line separators after package, single-line and multi-line comments and class/interface/abstract declarations.") class EmptyLinesCheck extends LineCheckBase { - /** number of empty lines to allow - **/ + **/ public var max:Int; /** allow empty lines after a single line comment - **/ + **/ public var allowEmptyLineAfterSingleLineComment:Bool; /** allow empty lines after a mutli line comment - **/ + **/ public var allowEmptyLineAfterMultiLineComment:Bool; /** require an empty line after package definition - **/ + **/ public var requireEmptyLineAfterPackage:Bool; /** require an empty line after class keyword - **/ + **/ public var requireEmptyLineAfterClass:Bool; /** require an empty line after interface keyword - **/ + **/ public var requireEmptyLineAfterInterface:Bool; /** require an empty line after abstract keyword - **/ + **/ public var requireEmptyLineAfterAbstract:Bool; public function new() { @@ -70,8 +69,10 @@ class EmptyLinesCheck extends LineCheckBase { if (ranges.length == 1) { switch (ranges[0].type) { case TEXT: - case COMMENT(isBlock): if (isBlock) continue; - case STRING(isInterpolated): continue; + case COMMENT(isBlock): + if (isBlock) continue; + case STRING(isInterpolated): + continue; } } @@ -127,35 +128,39 @@ class EmptyLinesCheck extends LineCheckBase { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [{ - propertyName: "max", - value: 1 - }], - properties: [{ - propertyName: "allowEmptyLineAfterSingleLineComment", - values: [false, true] - }, - { - propertyName: "allowEmptyLineAfterMultiLineComment", - values: [false, true] - }, - { - propertyName: "requireEmptyLineAfterPackage", - values: [true, false] - }, + return [ { - propertyName: "requireEmptyLineAfterClass", - values: [true, false] - }, - { - propertyName: "requireEmptyLineAfterInterface", - values: [true, false] - }, - { - propertyName: "requireEmptyLineAfterAbstract", - values: [true, false] - }] - }]; + fixed: [{ + propertyName: "max", + value: 1 + }], + properties: [ + { + propertyName: "allowEmptyLineAfterSingleLineComment", + values: [false, true] + }, + { + propertyName: "allowEmptyLineAfterMultiLineComment", + values: [false, true] + }, + { + propertyName: "requireEmptyLineAfterPackage", + values: [true, false] + }, + { + propertyName: "requireEmptyLineAfterClass", + values: [true, false] + }, + { + propertyName: "requireEmptyLineAfterInterface", + values: [true, false] + }, + { + propertyName: "requireEmptyLineAfterAbstract", + values: [true, false] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/ExtendedEmptyLinesCheck.hx b/src/checkstyle/checks/whitespace/ExtendedEmptyLinesCheck.hx index 6d477ddc..7378155f 100644 --- a/src/checkstyle/checks/whitespace/ExtendedEmptyLinesCheck.hx +++ b/src/checkstyle/checks/whitespace/ExtendedEmptyLinesCheck.hx @@ -4,49 +4,48 @@ import checkstyle.checks.whitespace.ListOfEmptyLines.EmptyLineRange; /** Checks for consecutive empty lines. - **/ +**/ @name("ExtendedEmptyLines") @desc("Checks for consecutive empty lines.") class ExtendedEmptyLinesCheck extends Check { - /** number of empty lines to allow / enforce (used by "exact", "upto" and "atleast" policies) - **/ + **/ public var max:Int; /** skips single line type definitions - **/ + **/ public var skipSingleLineTypes:Bool; /** "defaultPolicy" applies to all places not in "ignore", "none", "exact", "upto" or "atleast" - **/ + **/ public var defaultPolicy:EmptyLinesPolicy; /** list of places to ignore - **/ + **/ public var ignore:Array; /** list of places where no empty line is permitted - **/ + **/ public var none:Array; /** list of places where exactly "max" empty lines are required - **/ + **/ public var exact:Array; /** list of places where up to "max" empty lines are permitted - **/ + **/ public var upto:Array; /** list of places where at least "max" empty lines are required - **/ + **/ public var atleast:Array; var placemap:Map; @@ -68,11 +67,11 @@ class ExtendedEmptyLinesCheck extends Check { function buildPolicyMap() { placemap = new Map(); - for (place in ignore) placemap.set (place, IGNORE); - for (place in none) placemap.set (place, NONE); - for (place in exact) placemap.set (place, EXACT); - for (place in upto) placemap.set (place, UPTO); - for (place in atleast) placemap.set (place, ATLEAST); + for (place in ignore) placemap.set(place, IGNORE); + for (place in none) placemap.set(place, NONE); + for (place in exact) placemap.set(place, EXACT); + for (place in upto) placemap.set(place, UPTO); + for (place in atleast) placemap.set(place, ATLEAST); } function getPolicy(place:EmptyLinesPlace):EmptyLinesPolicy { @@ -110,19 +109,19 @@ class ExtendedEmptyLinesCheck extends Check { } function checkPackages(emptyLines:ListOfEmptyLines) { - if (isIgnored([BEFOREPACKAGE, AFTERPACKAGE])) return; + if (isIgnored([BEFORE_PACKAGE, AFTER_PACKAGE])) return; var root:TokenTree = checker.getTokenTree(); var packages:Array = root.filter([Kwd(KwdPackage)], ALL); for (pack in packages) { - checkBetweenToken(emptyLines, null, pack, getPolicy(BEFOREPACKAGE), "before package"); - checkBetweenToken(emptyLines, pack, pack.nextSibling, getPolicy(AFTERPACKAGE), "after package"); + checkBetweenToken(emptyLines, null, pack, getPolicy(BEFORE_PACKAGE), "before package"); + checkBetweenToken(emptyLines, pack, pack.nextSibling, getPolicy(AFTER_PACKAGE), "after package"); } } function checkImports(emptyLines:ListOfEmptyLines) { - if (isIgnored([AFTERIMPORTS, BEFOREUSING, BETWEENIMPORTS])) return; + if (isIgnored([AFTER_IMPORTS, BEFORE_USING, BETWEEN_IMPORTS])) return; var root:TokenTree = checker.getTokenTree(); var imports:Array = root.filter([Kwd(KwdImport), Kwd(KwdUsing)], ALL); @@ -133,7 +132,7 @@ class ExtendedEmptyLinesCheck extends Check { if (lastImport.nextSibling != null) { switch (lastImport.nextSibling.tok) { case Kwd(KwdAbstract), Kwd(KwdClass), Kwd(KwdEnum), Kwd(KwdInterface), Kwd(KwdTypedef): - checkBetweenToken(emptyLines, lastImport, lastImport.nextSibling, getPolicy(AFTERIMPORTS), "after imports/using"); + checkBetweenToken(emptyLines, lastImport, lastImport.nextSibling, getPolicy(AFTER_IMPORTS), "after imports/using"); default: } } @@ -142,21 +141,21 @@ class ExtendedEmptyLinesCheck extends Check { var imp:TokenTree = imports[index]; var prev:TokenTree = imp.previousSibling; if (prev == null) continue; - if (imp.is(Kwd(KwdUsing))) { - if (prev.is(Kwd(KwdImport))) { - checkBetweenToken(emptyLines, prev, imp, getPolicy(BEFOREUSING), "between import and using"); + if (imp.is(Kwd(KwdUsing))) { + if (prev.is(Kwd(KwdImport))) { + checkBetweenToken(emptyLines, prev, imp, getPolicy(BEFORE_USING), "between import and using"); continue; } } else { - if (prev.is(Kwd(KwdUsing))) { - checkBetweenToken(emptyLines, prev, imp, getPolicy(BEFOREUSING), "between import and using"); + if (prev.is(Kwd(KwdUsing))) { + checkBetweenToken(emptyLines, prev, imp, getPolicy(BEFORE_USING), "between import and using"); continue; } } switch (prev.tok) { case Kwd(KwdImport), Kwd(KwdUsing), Comment(_), CommentLine(_): - checkBetweenToken(emptyLines, prev, imp, getPolicy(BETWEENIMPORTS), "between imports/using"); + checkBetweenToken(emptyLines, prev, imp, getPolicy(BETWEEN_IMPORTS), "between imports/using"); default: } } @@ -180,25 +179,27 @@ class ExtendedEmptyLinesCheck extends Check { var pos:Position = type.getPos(); if (skipSingleLineTypes && (checker.getLinePos(pos.min).line - checker.getLinePos(pos.max).line == 0)) continue; switch (type.tok) { - case Kwd(KwdAbstract): checkAbstract(emptyLines, type); - case Kwd(KwdClass): checkClass(emptyLines, type); + case Kwd(KwdAbstract): + checkAbstract(emptyLines, type); + case Kwd(KwdClass): + checkClass(emptyLines, type); case Kwd(KwdEnum): - if (isIgnored([BEGINENUM, ENDENUM, BETWEENENUMFIELDS, TYPEDEFINITION])) continue; + if (isIgnored([BEGIN_ENUM, END_ENUM, BETWEEN_ENUM_FIELDS, TYPE_DEFINITION])) continue; - checkType(emptyLines, type, getPolicy(BEGINENUM), getPolicy(ENDENUM), function(child:TokenTree, next:TokenTree):PolicyAndWhat { - return makePolicyAndWhat(getPolicy(BETWEENENUMFIELDS), "between type fields"); + checkType(emptyLines, type, getPolicy(BEGIN_ENUM), getPolicy(END_ENUM), function(child:TokenTree, next:TokenTree):PolicyAndWhat { + return makePolicyAndWhat(getPolicy(BETWEEN_ENUM_FIELDS), "between type fields"); }); case Kwd(KwdInterface): - if (isIgnored([BEGININTERFACE, ENDINTERFACE, BETWEENINTERFACEFIELDS, TYPEDEFINITION])) continue; + if (isIgnored([BEGIN_INTERFACE, END_INTERFACE, BETWEEN_INTERFACE_FIELDS, TYPE_DEFINITION])) continue; - checkType(emptyLines, type, getPolicy(BEGININTERFACE), getPolicy(ENDINTERFACE), function(child:TokenTree, next:TokenTree):PolicyAndWhat { - return makePolicyAndWhat(getPolicy(BETWEENINTERFACEFIELDS), "between type fields"); + checkType(emptyLines, type, getPolicy(BEGIN_INTERFACE), getPolicy(END_INTERFACE), function(child:TokenTree, next:TokenTree):PolicyAndWhat { + return makePolicyAndWhat(getPolicy(BETWEEN_INTERFACE_FIELDS), "between type fields"); }); case Kwd(KwdTypedef): - if (isIgnored([BEGINTYPEDEF, ENDTYPEDEF, BETWEENTYPEDEFFIELDS, TYPEDEFINITION])) continue; + if (isIgnored([BEGIN_TYPEDEF, END_TYPEDEF, BETWEEN_TYPEDEF_FIELDS, TYPE_DEFINITION])) continue; - checkType(emptyLines, type, getPolicy(BEGINTYPEDEF), getPolicy(ENDTYPEDEF), function(child:TokenTree, next:TokenTree):PolicyAndWhat { - return makePolicyAndWhat(getPolicy(BETWEENTYPEDEFFIELDS), "between type fields"); + checkType(emptyLines, type, getPolicy(BEGIN_TYPEDEF), getPolicy(END_TYPEDEF), function(child:TokenTree, next:TokenTree):PolicyAndWhat { + return makePolicyAndWhat(getPolicy(BETWEEN_TYPEDEF_FIELDS), "between type fields"); }); default: } @@ -206,15 +207,17 @@ class ExtendedEmptyLinesCheck extends Check { } function checkBetweenTypes(emptyLines:ListOfEmptyLines, types:Array) { - if (isIgnored([BETWEENTYPES])) return; + if (isIgnored([BETWEEN_TYPES])) return; for (index in 1...types.length) { var type:TokenTree = types[index]; var sibling:TokenTree = type.previousSibling; var prevType:TokenTree = types[index - 1]; if ((sibling != null) && (sibling != prevType)) { switch (sibling.tok) { - case Comment(_): type = sibling; - case CommentLine(_): type = sibling; + case Comment(_): + type = sibling; + case CommentLine(_): + type = sibling; default: } } @@ -222,40 +225,49 @@ class ExtendedEmptyLinesCheck extends Check { if (skipSingleLineTypes && (checker.getLinePos(prevPos.min).line - checker.getLinePos(prevPos.max).line == 0)) continue; var startLine:Int = checker.getLinePos(prevPos.max).line; var endLine:Int = checker.getLinePos(type.getPos().min).line; - checkBetween(emptyLines, startLine, endLine, getPolicy(BETWEENTYPES), "between types"); + checkBetween(emptyLines, startLine, endLine, getPolicy(BETWEEN_TYPES), "between types"); } } function checkAbstract(emptyLines:ListOfEmptyLines, typeToken:TokenTree) { - if (isIgnored([BEGINABSTRACT, ENDABSTRACT, BETWEENABSTRACTMETHODS, AFTERABSTRACTVARS, BETWEENABSTRACTVARS, TYPEDEFINITION])) return; + if (isIgnored([ + BEGIN_ABSTRACT, + END_ABSTRACT, + BETWEEN_ABSTRACT_METHODS, + AFTER_ABSTRACT_VARS, + BETWEEN_ABSTRACT_VARS, + TYPE_DEFINITION + ])) { + return; + } - checkType(emptyLines, typeToken, getPolicy(BEGINABSTRACT), getPolicy(ENDABSTRACT), function(child:TokenTree, next:TokenTree):PolicyAndWhat { + checkType(emptyLines, typeToken, getPolicy(BEGIN_ABSTRACT), getPolicy(END_ABSTRACT), function(child:TokenTree, next:TokenTree):PolicyAndWhat { var isFuncChild:Bool = child.is(Kwd(KwdFunction)); var isVarChild:Bool = child.is(Kwd(KwdVar)); if (!isVarChild && !isFuncChild) return null; var type:EmptyLinesFieldType = detectNextFieldType(next); if (type == OTHER) return null; - if (isFuncChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(BETWEENABSTRACTMETHODS), "between abstract functions"); - if (isVarChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(AFTERABSTRACTVARS), "after abstract vars"); - if (isFuncChild && (type == VAR)) return makePolicyAndWhat(getPolicy(AFTERABSTRACTVARS), "after abstract vars"); - return makePolicyAndWhat(getPolicy(BETWEENABSTRACTVARS), "between abstract vars"); + if (isFuncChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(BETWEEN_ABSTRACT_METHODS), "between abstract functions"); + if (isVarChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(AFTER_ABSTRACT_VARS), "after abstract vars"); + if (isFuncChild && (type == VAR)) return makePolicyAndWhat(getPolicy(AFTER_ABSTRACT_VARS), "after abstract vars"); + return makePolicyAndWhat(getPolicy(BETWEEN_ABSTRACT_VARS), "between abstract vars"); }); } function checkClass(emptyLines:ListOfEmptyLines, typeToken:TokenTree) { var places:Array = [ - BEGINCLASS, - ENDCLASS, - BETWEENCLASSMETHODS, - AFTERCLASSVARS, - BETWEENCLASSSTATICVARS, - BETWEENCLASSVARS, - AFTERCLASSSTATICVARS, - TYPEDEFINITION + BEGIN_CLASS, + END_CLASS, + BETWEEN_CLASS_METHODS, + AFTER_CLASS_VARS, + BETWEEN_CLASS_STATIC_VARS, + BETWEEN_CLASS_VARS, + AFTER_CLASS_STATIC_VARS, + TYPE_DEFINITION ]; if (isIgnored(places)) return; - checkType(emptyLines, typeToken, getPolicy(BEGINCLASS), getPolicy(ENDCLASS), function(child:TokenTree, next:TokenTree):PolicyAndWhat { + checkType(emptyLines, typeToken, getPolicy(BEGIN_CLASS), getPolicy(END_CLASS), function(child:TokenTree, next:TokenTree):PolicyAndWhat { while (next != null) { if (!next.isComment()) break; next = next.nextSibling; @@ -267,16 +279,16 @@ class ExtendedEmptyLinesCheck extends Check { if (!isVarChild && !isFuncChild) return null; var type:EmptyLinesFieldType = detectNextFieldType(next); if (type == OTHER) return null; - if (isFuncChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(BETWEENCLASSMETHODS), "between class methods"); - if (isVarChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(AFTERCLASSVARS), "after class vars"); - if (isFuncChild && (type == VAR)) return makePolicyAndWhat(getPolicy(AFTERCLASSVARS), "after class vars"); + if (isFuncChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(BETWEEN_CLASS_METHODS), "between class methods"); + if (isVarChild && (type == FUNCTION)) return makePolicyAndWhat(getPolicy(AFTER_CLASS_VARS), "after class vars"); + if (isFuncChild && (type == VAR)) return makePolicyAndWhat(getPolicy(AFTER_CLASS_VARS), "after class vars"); var isStaticChild:Bool = (child.filter([Kwd(KwdStatic)], FIRST).length > 0); var isStaticNext:Bool = (next.filter([Kwd(KwdStatic)], FIRST).length > 0); - if (isStaticChild && isStaticNext) return makePolicyAndWhat(getPolicy(BETWEENCLASSSTATICVARS), "between class static vars"); - if (!isStaticChild && !isStaticNext) return makePolicyAndWhat(getPolicy(BETWEENCLASSVARS), "between class vars"); - return makePolicyAndWhat(getPolicy(AFTERCLASSSTATICVARS), "after class static vars"); + if (isStaticChild && isStaticNext) return makePolicyAndWhat(getPolicy(BETWEEN_CLASS_STATIC_VARS), "between class static vars"); + if (!isStaticChild && !isStaticNext) return makePolicyAndWhat(getPolicy(BETWEEN_CLASS_VARS), "between class vars"); + return makePolicyAndWhat(getPolicy(AFTER_CLASS_STATIC_VARS), "after class static vars"); }); } @@ -298,14 +310,11 @@ class ExtendedEmptyLinesCheck extends Check { return OTHER; } - function checkType(emptyLines:ListOfEmptyLines, - typeToken:TokenTree, - beginPolicy:EmptyLinesPolicy, - endPolicy:EmptyLinesPolicy, - fieldPolicyProvider:FieldPolicyProvider) { + function checkType(emptyLines:ListOfEmptyLines, typeToken:TokenTree, beginPolicy:EmptyLinesPolicy, endPolicy:EmptyLinesPolicy, + fieldPolicyProvider:FieldPolicyProvider) { var brOpen = findTypeBrOpen(typeToken); if (brOpen == null) return; - checkBetweenToken(emptyLines, typeToken, brOpen, getPolicy(TYPEDEFINITION), "between type definition and left curly"); + checkBetweenToken(emptyLines, typeToken, brOpen, getPolicy(TYPE_DEFINITION), "between type definition and left curly"); var brClose:TokenTree = brOpen.getLastChild(); var start:Int = checker.getLinePos(brOpen.pos.max).line; var end:Int = checker.getLinePos(brClose.pos.min).line; @@ -320,7 +329,15 @@ class ExtendedEmptyLinesCheck extends Check { default: var next:TokenTree = child.nextSibling; if (next == null) continue; - if (next.is(BrClose)) continue; + switch (next.tok) { + case BrClose: + continue; + case CommentLine(_): + continue; + case Comment(_): + continue; + default: + } var policyAndWhat:PolicyAndWhat = fieldPolicyProvider(child, next); if (policyAndWhat == null) continue; checkBetweenFullToken(emptyLines, child, next, policyAndWhat.policy, policyAndWhat.whatMsg); @@ -330,7 +347,7 @@ class ExtendedEmptyLinesCheck extends Check { function findTypeBrOpen(parent:TokenTree):TokenTree { if (parent == null) return null; - var brOpens:Array = parent.filterCallback(function (tok:TokenTree, depth:Int):FilterResult { + var brOpens:Array = parent.filterCallback(function(tok:TokenTree, depth:Int):FilterResult { return switch (tok.tok) { case BrOpen: FOUND_SKIP_SUBTREE; default: GO_DEEPER; @@ -341,18 +358,20 @@ class ExtendedEmptyLinesCheck extends Check { } function checkFile(emptyLines:ListOfEmptyLines) { - if (isIgnored([ANYWHEREINFILE, BEFOREFILEEND])) return; + if (isIgnored([ANYWHERE_IN_FILE, BEFORE_FILE_END])) return; var ranges:Array = emptyLines.getRanges(0, checker.lines.length); for (range in ranges) { var line:Int = 0; switch (range) { case NONE: - case SINGLE(l): line = l; - case RANGE(start, end): line = end; + case SINGLE(l): + line = l; + case RANGE(start, end): + line = end; } - var result:EmptyLineRange = emptyLines.checkRange(getPolicy(ANYWHEREINFILE), max, range, line); - logEmptyRange(getPolicy(ANYWHEREINFILE), "anywhere in file", result); + var result:EmptyLineRange = emptyLines.checkRange(getPolicy(ANYWHERE_IN_FILE), max, range, line); + logEmptyRange(getPolicy(ANYWHERE_IN_FILE), "anywhere in file", result); } var range:EmptyLineRange = NONE; @@ -366,12 +385,12 @@ class ExtendedEmptyLinesCheck extends Check { if (end == checker.lines.length - 1) range = lastRange; } } - var result:EmptyLineRange = emptyLines.checkRange(getPolicy(BEFOREFILEEND), max, range, checker.lines.length - 1); - logEmptyRange(getPolicy(BEFOREFILEEND), "before file end", result); + var result:EmptyLineRange = emptyLines.checkRange(getPolicy(BEFORE_FILE_END), max, range, checker.lines.length - 1); + logEmptyRange(getPolicy(BEFORE_FILE_END), "before file end", result); } function checkFunctions(emptyLines:ListOfEmptyLines) { - if (isIgnored([INFUNCTION, AFTERLEFTCURLY, BEFORERIGHTCURLY])) return; + if (isIgnored([IN_FUNCTION, AFTER_LEFT_CURLY, BEFORE_RIGHT_CURLY])) return; var root:TokenTree = checker.getTokenTree(); var funcs:Array = root.filter([Kwd(KwdFunction)], ALL); @@ -382,7 +401,7 @@ class ExtendedEmptyLinesCheck extends Check { var pos:Position = func.getPos(); var start:Int = checker.getLinePos(pos.min).line; var end:Int = checker.getLinePos(pos.max).line; - checkLines(emptyLines, getPolicy(INFUNCTION), start, end, "inside functions", true); + checkLines(emptyLines, getPolicy(IN_FUNCTION), start, end, "inside functions", true); var brOpen:Array = func.filter([BrOpen], ALL); for (open in brOpen) { @@ -391,17 +410,24 @@ class ExtendedEmptyLinesCheck extends Check { var start:Int = checker.getLinePos(open.pos.max).line; var end:Int = checker.getLinePos(close.pos.min).line; if (start == end) continue; - checkLines(emptyLines, getPolicy(AFTERLEFTCURLY), start + 1, start + 1, "after left curly"); - checkLines(emptyLines, getPolicy(BEFORERIGHTCURLY), end - 1, end - 1, "before right curly"); + checkLines(emptyLines, getPolicy(AFTER_LEFT_CURLY), start + 1, start + 1, "after left curly"); + checkLines(emptyLines, getPolicy(BEFORE_RIGHT_CURLY), end - 1, end - 1, "before right curly"); } } } function checkComments(emptyLines:ListOfEmptyLines) { - if (isIgnored([AFTERMULTILINECOMMENT, AFTERSINGLELINECOMMENT])) return; + if (isIgnored([ + AFTER_MULTILINE_COMMENT, + AFTER_SINGLELINE_COMMENT, + BEFORE_MULTILINE_COMMENT, + BEFORE_SINGLELINE_COMMENT + ])) { + return; + } var root:TokenTree = checker.getTokenTree(); - var comments:Array = root.filterCallback(function (tok:TokenTree, depth:Int):FilterResult { + var comments:Array = root.filterCallback(function(tok:TokenTree, depth:Int):FilterResult { return switch (tok.tok) { case Comment(_): FOUND_SKIP_SUBTREE; case CommentLine(_): FOUND_SKIP_SUBTREE; @@ -411,14 +437,24 @@ class ExtendedEmptyLinesCheck extends Check { for (comment in comments) { var line:Int = checker.getLinePos(comment.pos.min).line; if (!~/^\s*(\/\/|\/\*)/.match(checker.lines[line])) continue; - line = checker.getLinePos(comment.getPos().max).line + 1; + var prevLine:Int = checker.getLinePos(comment.getPos().min).line - 1; + var nextLine:Int = checker.getLinePos(comment.getPos().max).line + 1; switch (comment.tok) { case Comment(_): - if ((comment.nextSibling != null) && (comment.nextSibling.isComment())) continue; - checkLines(emptyLines, getPolicy(AFTERMULTILINECOMMENT), line, line, "after comment"); + if ((comment.previousSibling != null) && (!comment.previousSibling.isComment())) { + checkLines(emptyLines, getPolicy(BEFORE_MULTILINE_COMMENT), prevLine, prevLine, "before comment"); + } + if ((comment.nextSibling == null) || (!comment.nextSibling.isComment())) { + checkLines(emptyLines, getPolicy(AFTER_MULTILINE_COMMENT), nextLine, nextLine, "after comment"); + } + case CommentLine(_): - if ((comment.nextSibling != null) && (comment.nextSibling.isComment())) continue; - checkLines(emptyLines, getPolicy(AFTERSINGLELINECOMMENT), line, line, "after comment"); + if ((comment.previousSibling != null) && (!comment.previousSibling.isComment())) { + checkLines(emptyLines, getPolicy(BEFORE_SINGLELINE_COMMENT), prevLine, prevLine, "before comment"); + } + if ((comment.nextSibling == null) || (!comment.nextSibling.isComment())) { + checkLines(emptyLines, getPolicy(AFTER_SINGLELINE_COMMENT), nextLine, nextLine, "after comment"); + } default: } } @@ -497,31 +533,37 @@ class ExtendedEmptyLinesCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [{ - propertyName: "max", - value: 1 - }], - properties: [{ - "propertyName": "skipSingleLineTypes", - "values": [false, true] - }, - { - "propertyName": "defaultPolicy", - "values": ["none", "exact", "upto", "atleast", "ignore"] - }, + return [ { - "propertyName": "none", - "values": [[ - BEFOREPACKAGE, - BETWEENIMPORTS, - BEFOREUSING, - TYPEDEFINITION, - AFTERLEFTCURLY, - BEFORERIGHTCURLY - ]] - }] - }]; + fixed: [{ + propertyName: "max", + value: 1 + }], + properties: [ + { + "propertyName": "skipSingleLineTypes", + "values": [false, true] + }, + { + "propertyName": "defaultPolicy", + "values": ["none", "exact", "upto", "atleast", "ignore"] + }, + { + "propertyName": "none", + "values": [ + [ + BEFORE_PACKAGE, + BETWEEN_IMPORTS, + BEFORE_USING, + TYPE_DEFINITION, + AFTER_LEFT_CURLY, + BEFORE_RIGHT_CURLY + ] + ] + } + ] + } + ]; } } @@ -539,7 +581,7 @@ typedef PolicyAndWhat = { - exact = exactly "max" empty line(s) required - upto = up to "max" empty line(s) allowed (0 - "max") - atleast = at least "max" empty lines required - **/ +**/ @:enum abstract EmptyLinesPolicy(String) { var IGNORE = "ignore"; @@ -592,49 +634,44 @@ enum EmptyLinesFieldType { - endTypedef = before typedef right curly - inFunction = anywhere inside function body - typeDefinition = between type and left curly - **/ +**/ @:enum abstract EmptyLinesPlace(String) { - var BEFOREPACKAGE = "beforePackage"; - var AFTERPACKAGE = "afterPackage"; - var BETWEENIMPORTS = "betweenImports"; - var BEFOREUSING = "beforeUsing"; - var AFTERIMPORTS = "afterImports"; - - var ANYWHEREINFILE = "anywhereInFile"; - var BETWEENTYPES = "betweenTypes"; - var BEFOREFILEEND = "beforeFileEnd"; - var INFUNCTION = "inFunction"; - var AFTERLEFTCURLY = "afterLeftCurly"; - var BEFORERIGHTCURLY = "beforeRightCurly"; - var TYPEDEFINITION = "typeDefinition"; - - var BEGINCLASS = "beginClass"; - var ENDCLASS = "endClass"; - var AFTERCLASSSTATICVARS = "afterClassStaticVars"; - var AFTERCLASSVARS = "afterClassVars"; - var BETWEENCLASSSTATICVARS = "betweenClassStaticVars"; - var BETWEENCLASSVARS = "betweenClassVars"; - var BETWEENCLASSMETHODS = "betweenClassMethods"; - - var BEGINABSTRACT = "beginAbstract"; - var ENDABSTRACT = "endAbstract"; - var AFTERABSTRACTVARS = "afterAbstractVars"; - var BETWEENABSTRACTVARS = "betweenAbstractVars"; - var BETWEENABSTRACTMETHODS = "betweenAbstractMethods"; - - var BEGININTERFACE = "beginInterface"; - var ENDINTERFACE = "endInterface"; - var BETWEENINTERFACEFIELDS = "betweenInterfaceFields"; - - var BEGINENUM = "beginEnum"; - var ENDENUM = "endEnum"; - var BETWEENENUMFIELDS = "betweenEnumFields"; - - var BEGINTYPEDEF = "beginTypedef"; - var ENDTYPEDEF = "endTypedef"; - var BETWEENTYPEDEFFIELDS = "betweenTypedefFields"; - - var AFTERSINGLELINECOMMENT = "afterSingleLineComment"; - var AFTERMULTILINECOMMENT = "afterMultiLineComment"; + var BEFORE_PACKAGE = "beforePackage"; + var AFTER_PACKAGE = "afterPackage"; + var BETWEEN_IMPORTS = "betweenImports"; + var BEFORE_USING = "beforeUsing"; + var AFTER_IMPORTS = "afterImports"; + var ANYWHERE_IN_FILE = "anywhereInFile"; + var BETWEEN_TYPES = "betweenTypes"; + var BEFORE_FILE_END = "beforeFileEnd"; + var IN_FUNCTION = "inFunction"; + var AFTER_LEFT_CURLY = "afterLeftCurly"; + var BEFORE_RIGHT_CURLY = "beforeRightCurly"; + var TYPE_DEFINITION = "typeDefinition"; + var BEGIN_CLASS = "beginClass"; + var END_CLASS = "endClass"; + var AFTER_CLASS_STATIC_VARS = "afterClassStaticVars"; + var AFTER_CLASS_VARS = "afterClassVars"; + var BETWEEN_CLASS_STATIC_VARS = "betweenClassStaticVars"; + var BETWEEN_CLASS_VARS = "betweenClassVars"; + var BETWEEN_CLASS_METHODS = "betweenClassMethods"; + var BEGIN_ABSTRACT = "beginAbstract"; + var END_ABSTRACT = "endAbstract"; + var AFTER_ABSTRACT_VARS = "afterAbstractVars"; + var BETWEEN_ABSTRACT_VARS = "betweenAbstractVars"; + var BETWEEN_ABSTRACT_METHODS = "betweenAbstractMethods"; + var BEGIN_INTERFACE = "beginInterface"; + var END_INTERFACE = "endInterface"; + var BETWEEN_INTERFACE_FIELDS = "betweenInterfaceFields"; + var BEGIN_ENUM = "beginEnum"; + var END_ENUM = "endEnum"; + var BETWEEN_ENUM_FIELDS = "betweenEnumFields"; + var BEGIN_TYPEDEF = "beginTypedef"; + var END_TYPEDEF = "endTypedef"; + var BETWEEN_TYPEDEF_FIELDS = "betweenTypedefFields"; + var AFTER_SINGLELINE_COMMENT = "afterSingleLineComment"; + var AFTER_MULTILINE_COMMENT = "afterMultiLineComment"; + var BEFORE_SINGLELINE_COMMENT = "beforeSingleLineComment"; + var BEFORE_MULTILINE_COMMENT = "beforeMultiLineComment"; } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/IndentationCharacterCheck.hx b/src/checkstyle/checks/whitespace/IndentationCharacterCheck.hx index 9b7d163b..fac472c7 100644 --- a/src/checkstyle/checks/whitespace/IndentationCharacterCheck.hx +++ b/src/checkstyle/checks/whitespace/IndentationCharacterCheck.hx @@ -2,21 +2,20 @@ package checkstyle.checks.whitespace; /** Checks indentation character (tab/space, default is tab). - **/ +**/ @name("IndentationCharacter") @desc("Checks indentation character (tab/space, default is tab).") class IndentationCharacterCheck extends LineCheckBase { - /** set indentation to - tab = tab - space = space - **/ + **/ public var character:IndentationCharacterCheckCharacter; /** ignore lines that match regex - **/ + **/ public var ignorePattern:String; public function new() { @@ -56,7 +55,7 @@ class IndentationCharacterCheck extends LineCheckBase { indentation with - tab = tabs - space = space - **/ +**/ @:enum abstract IndentationCharacterCheckCharacter(String) { var TAB = "tab"; diff --git a/src/checkstyle/checks/whitespace/IndentationCheck.hx b/src/checkstyle/checks/whitespace/IndentationCheck.hx index e38a677b..a8f7b47d 100644 --- a/src/checkstyle/checks/whitespace/IndentationCheck.hx +++ b/src/checkstyle/checks/whitespace/IndentationCheck.hx @@ -2,35 +2,34 @@ package checkstyle.checks.whitespace; /** Checks correct indentation - **/ +**/ @name("Indentation") @desc("Checks correct indentation") class IndentationCheck extends Check { - /** - character sequence to use for indentation + character sequence to use for indentation - "tab" for using tabs - a string containing as many spaces as one indentation level requires - **/ + **/ public var character:IndentationCheckCharacter; /** - ignore indentation of conditionals (same as setting conditionalPolicy to ignore) - **/ + ignore indentation of conditionals (same as setting conditionalPolicy to ignore) + **/ public var ignoreConditionals:Bool; /** - indentation of conditional statements + indentation of conditional statements - ignore = ignores conditioonals, same as "ignoreConditionals" - fixed_zero = contitionals have to start at the beginning of a line (only where conditional is the first statement) - aligned = align wih surrounding code - aligned_increase = align wih surrounding code and increase indentation of enclosed code by +1 - **/ + **/ public var conditionalPolicy:ConditionalIndentationPolicy; /** - ignore indentation of comments - **/ + ignore indentation of comments + **/ public var ignoreComments:Bool; /** @@ -38,7 +37,7 @@ class IndentationCheck extends Check { - none = wrapped statements must have the same indentation as parent - exact = wrapped statemenmts must have a +1 indentation in relation to parent - larger = wrapped statements must have a +1 or larger indentation in relation to parent - **/ + **/ public var wrapPolicy:WrappedIndentationPolicy; public function new() { @@ -220,12 +219,14 @@ class IndentationCheck extends Check { var isFirst:Bool = ~/^\s*#$/.match(prefix); switch (conditionalPolicy) { - case IGNORE: return; + case IGNORE: + return; case FIXED_ZERO: if (!isFirst) return; lineIndentation[linePos.line] = 0; return; - case ALIGNED: return; + case ALIGNED: + return; case ALIGNED_INCREASE: } @@ -403,39 +404,43 @@ class IndentationCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "character", - values: [ - TAB, - EIGHT_SPACES, - SEVEN_SPACES, - SIX_SPACES, - FIVE_SPACES, - FOUR_SPACES, - THREE_SPACES, - TWO_SPACES, - ONE_SPACE - ] - }, - { - propertyName: "conditionalPolicy", - values: [FIXED_ZERO, ALIGNED, ALIGNED_INCREASE, IGNORE] - }, - { - propertyName: "ignoreConditionals", - values: [true, false] - }, + return [ { - propertyName: "ignoreComments", - values: [true, false] - }, - { - propertyName: "wrapPolicy", - values: [NONE, EXACT, LARGER] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "character", + values: [ + TAB, + EIGHT_SPACES, + SEVEN_SPACES, + SIX_SPACES, + FIVE_SPACES, + FOUR_SPACES, + THREE_SPACES, + TWO_SPACES, + ONE_SPACE + ] + }, + { + propertyName: "conditionalPolicy", + values: [FIXED_ZERO, ALIGNED, ALIGNED_INCREASE, IGNORE] + }, + { + propertyName: "ignoreConditionals", + values: [true, false] + }, + { + propertyName: "ignoreComments", + values: [true, false] + }, + { + propertyName: "wrapPolicy", + values: [NONE, EXACT, LARGER] + } + ] + } + ]; } } diff --git a/src/checkstyle/checks/whitespace/LineCheckBase.hx b/src/checkstyle/checks/whitespace/LineCheckBase.hx index 8b991ef6..6ad50d8a 100644 --- a/src/checkstyle/checks/whitespace/LineCheckBase.hx +++ b/src/checkstyle/checks/whitespace/LineCheckBase.hx @@ -2,13 +2,11 @@ package checkstyle.checks.whitespace; /** base class for line based whitespace checks - **/ +**/ @ignore("base class for line based whitespace checks") class LineCheckBase extends Check { - var currentState:RangeType; var skipOverInitialQuote:Bool; - var commentStartRE:EReg; var commentBlockEndRE:EReg; var stringStartRE:EReg; @@ -41,7 +39,7 @@ class LineCheckBase extends Check { case STRING(isInterpolated): handleStringState(line, ranges, currentStart, isInterpolated); }; } - if (line.length == 0) ranges.push({ type: currentState, start: 0, end: 0 }); + if (line.length == 0) ranges.push({type: currentState, start: 0, end: 0}); return ranges; } @@ -53,7 +51,7 @@ class LineCheckBase extends Check { if (foundCommentStart && commentStart < stringStart) { if (commentStart > currentStart) { - ranges.push({ type: currentState, start: currentStart, end: commentStart }); + ranges.push({type: currentState, start: currentStart, end: commentStart}); } currentState = COMMENT(commentStartRE.matched(1) == "*"); @@ -61,7 +59,7 @@ class LineCheckBase extends Check { } else if (foundStringStart && stringStart < commentStart) { if (stringStart > currentStart) { - ranges.push({ type: currentState, start: currentStart, end: stringStart }); + ranges.push({type: currentState, start: currentStart, end: stringStart}); } skipOverInitialQuote = true; @@ -69,7 +67,7 @@ class LineCheckBase extends Check { return stringStart; } else { - ranges.push({ type: currentState, start: currentStart, end: line.length }); + ranges.push({type: currentState, start: currentStart, end: line.length}); return line.length; } @@ -78,13 +76,13 @@ class LineCheckBase extends Check { function handleCommentState(line:String, ranges:Array, currentStart:Int, isBlock:Bool):Int { if (isBlock && commentBlockEndRE.matchSub(line, currentStart)) { var commentEnd = commentBlockEndRE.matchedPos().pos + 2; - ranges.push({ type: currentState, start: currentStart, end: commentEnd }); + ranges.push({type: currentState, start: currentStart, end: commentEnd}); currentState = TEXT; return commentEnd; } else { - ranges.push({ type: currentState, start: currentStart, end: line.length }); + ranges.push({type: currentState, start: currentStart, end: line.length}); if (!isBlock) currentState = TEXT; return line.length; @@ -98,13 +96,13 @@ class LineCheckBase extends Check { if (re.match(line.substring(adjustedStart))) { var matchedPos = re.matchedPos(); var stringEnd = adjustedStart + matchedPos.pos + matchedPos.len; - ranges.push({ type: currentState, start: currentStart, end: stringEnd }); + ranges.push({type: currentState, start: currentStart, end: stringEnd}); currentState = TEXT; return stringEnd; } else { - ranges.push({ type: currentState, start: currentStart, end: line.length }); + ranges.push({type: currentState, start: currentStart, end: line.length}); return line.length; } diff --git a/src/checkstyle/checks/whitespace/ListOfEmptyLines.hx b/src/checkstyle/checks/whitespace/ListOfEmptyLines.hx index 1cf55c29..58e22781 100644 --- a/src/checkstyle/checks/whitespace/ListOfEmptyLines.hx +++ b/src/checkstyle/checks/whitespace/ListOfEmptyLines.hx @@ -5,7 +5,7 @@ import checkstyle.checks.whitespace.ExtendedEmptyLinesCheck.EmptyLinesPolicy; /** holds list of empty lines and provides some helper functions line numbers start at 0 - **/ +**/ class ListOfEmptyLines { var lines:Array; var lineRanges:Array; @@ -18,7 +18,7 @@ class ListOfEmptyLines { /** adds a new empty line number @param line - line number of empty line - **/ + **/ public function add(line:Int) { lines.push(line); } @@ -30,41 +30,55 @@ class ListOfEmptyLines { @param range - range to check @param line - line to check @return EmptyLineRange returns matching range or NONE - **/ + **/ public function checkRange(policy:EmptyLinesPolicy, max:Int, range:EmptyLineRange, line:Int):EmptyLineRange { switch (policy) { - case IGNORE: return NONE; - case NONE: return range; - case EXACT: return checkRangeExact(range, max, line); - case UPTO: return checkRangeUpto(range, max, line); - case ATLEAST: return checkRangeAtLeast(range, max, line); + case IGNORE: + return NONE; + case NONE: + return range; + case EXACT: + return checkRangeExact(range, max, line); + case UPTO: + return checkRangeUpto(range, max, line); + case ATLEAST: + return checkRangeAtLeast(range, max, line); } return range; } function checkRangeExact(range:EmptyLineRange, max:Int, line:Int):EmptyLineRange { switch (range) { - case NONE: return SINGLE(line); - case SINGLE(l): if (max == 1) return NONE; - case RANGE(rangeStart, rangeEnd): if (1 + rangeEnd - rangeStart == max) return NONE; + case NONE: + return SINGLE(line); + case SINGLE(l): + if (max == 1) return NONE; + case RANGE(rangeStart, rangeEnd): + if (1 + rangeEnd - rangeStart == max) return NONE; } return range; } function checkRangeUpto(range:EmptyLineRange, max:Int, line:Int):EmptyLineRange { switch (range) { - case NONE: return NONE; - case SINGLE(l): if (max >= 1) return NONE; - case RANGE(rangeStart, rangeEnd): if (1 + rangeEnd - rangeStart <= max) return NONE; + case NONE: + return NONE; + case SINGLE(l): + if (max >= 1) return NONE; + case RANGE(rangeStart, rangeEnd): + if (1 + rangeEnd - rangeStart <= max) return NONE; }; return range; } function checkRangeAtLeast(range:EmptyLineRange, max:Int, line:Int):EmptyLineRange { switch (range) { - case NONE: return SINGLE(line); - case SINGLE(l): if (max == 1) return NONE; - case RANGE(rangeStart, rangeEnd): if (1 + rangeEnd - rangeStart >= max) return NONE; + case NONE: + return SINGLE(line); + case SINGLE(l): + if (max == 1) return NONE; + case RANGE(rangeStart, rangeEnd): + if (1 + rangeEnd - rangeStart >= max) return NONE; }; return range; } @@ -76,13 +90,14 @@ class ListOfEmptyLines { @param start - start line number (inclusive) @param end - end line number (inclusive) @return EmptyLineRange matching range or NONE - **/ + **/ public function checkPolicySingleRange(policy:EmptyLinesPolicy, max:Int, start:Int, end:Int):EmptyLineRange { if (start > end) throw "*** wrong order!! *** " + start + " " + end; var range:Array = getRanges(start, end); switch (policy) { - case IGNORE: return NONE; + case IGNORE: + return NONE; case NONE: if (range.length == 0) return NONE; return range[0]; @@ -108,7 +123,7 @@ class ListOfEmptyLines { @param startLine - start line number (inclusive) @param endLine - end line number (inclusive) @return Array list of emtpy line ranges - **/ + **/ public function getRanges(startLine:Int, endLine:Int):Array { if (lineRanges == null) lineRanges = makeRanges(); var results:Array = []; @@ -137,19 +152,19 @@ class ListOfEmptyLines { continue; } if (current == start) { - results.push (SINGLE(start)); + results.push(SINGLE(start)); } else { - results.push (RANGE(start, current)); + results.push(RANGE(start, current)); } start = val; current = val; } if (current == start) { - results.push (SINGLE(start)); + results.push(SINGLE(start)); } else { - results.push (RANGE(start, current)); + results.push(RANGE(start, current)); } return results; } diff --git a/src/checkstyle/checks/whitespace/OperatorWhitespaceCheck.hx b/src/checkstyle/checks/whitespace/OperatorWhitespaceCheck.hx index a51b592e..b4084780 100644 --- a/src/checkstyle/checks/whitespace/OperatorWhitespaceCheck.hx +++ b/src/checkstyle/checks/whitespace/OperatorWhitespaceCheck.hx @@ -6,11 +6,10 @@ import checkstyle.checks.whitespace.WhitespaceCheckBase.WhitespaceUnaryPolicy; /** Checks that whitespace is present or absent around a operators. - **/ +**/ @name("OperatorWhitespace") @desc("Checks that whitespace is present or absent around a operators.") class OperatorWhitespaceCheck extends WhitespaceCheckBase { - /** policy for "=", "+=", "-=", "*=", "/=", "<<=", ">>=", ">>>=", "&=", "|=", "^=" - around = enforce whitespace before and after operator @@ -18,7 +17,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var assignOpPolicy:WhitespacePolicy; /** @@ -26,7 +25,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - inner = enforce whitespace between unary operator and operand - none = enforce no whitespace between unary operator and operand - ignore = skip checks - **/ + **/ public var unaryOpPolicy:WhitespaceUnaryPolicy; /** @@ -36,7 +35,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var ternaryOpPolicy:WhitespacePolicy; /** @@ -46,7 +45,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var arithmeticOpPolicy:WhitespacePolicy; /** @@ -56,7 +55,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var compareOpPolicy:WhitespacePolicy; /** @@ -66,7 +65,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var bitwiseOpPolicy:WhitespacePolicy; /** @@ -76,7 +75,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var boolOpPolicy:WhitespacePolicy; /** @@ -86,7 +85,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var intervalOpPolicy:WhitespacePolicy; /** @@ -96,7 +95,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var arrowPolicy:WhitespacePolicy; /** @@ -106,7 +105,7 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var functionArgPolicy:WhitespacePolicy; public function new() { @@ -140,29 +139,24 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { function checkAssignOps(root:TokenTree) { checkTokens(root, [ - Binop(OpAssign), - Binop(OpAssignOp(OpAdd)), - Binop(OpAssignOp(OpSub)), - Binop(OpAssignOp(OpMult)), - Binop(OpAssignOp(OpDiv)), - Binop(OpAssignOp(OpMod)), - Binop(OpAssignOp(OpShl)), - Binop(OpAssignOp(OpShr)), - Binop(OpAssignOp(OpUShr)), - Binop(OpAssignOp(OpOr)), - Binop(OpAssignOp(OpAnd)), - Binop(OpAssignOp(OpXor)) - ], assignOpPolicy); + Binop(OpAssign), + Binop(OpAssignOp(OpAdd)), + Binop(OpAssignOp(OpSub)), + Binop(OpAssignOp(OpMult)), + Binop(OpAssignOp(OpDiv)), + Binop(OpAssignOp(OpMod)), + Binop(OpAssignOp(OpShl)), + Binop(OpAssignOp(OpShr)), + Binop(OpAssignOp(OpUShr)), + Binop(OpAssignOp(OpOr)), + Binop(OpAssignOp(OpAnd)), + Binop(OpAssignOp(OpXor)) + ], assignOpPolicy); } function checkUnaryOps(root:TokenTree) { if ((unaryOpPolicy == null) || (unaryOpPolicy == IGNORE)) return; - var tokens:Array = root.filter([ - Unop(OpNegBits), - Unop(OpNot), - Unop(OpIncrement), - Unop(OpDecrement) - ], ALL); + var tokens:Array = root.filter([Unop(OpNegBits), Unop(OpNot), Unop(OpIncrement), Unop(OpDecrement)], ALL); for (token in tokens) { if (isPosSuppressed(token.pos)) continue; @@ -185,42 +179,33 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { } function checkArithmeticOps(root:TokenTree) { - checkTokens(root, [ - Binop(OpAdd), - Binop(OpSub), - Binop(OpMult), - Binop(OpDiv), - Binop(OpMod) - ], arithmeticOpPolicy); + checkTokens(root, [Binop(OpAdd), Binop(OpSub), Binop(OpMult), Binop(OpDiv), Binop(OpMod)], arithmeticOpPolicy); } function checkCompareOps(root:TokenTree) { checkTokens(root, [ - Binop(OpGt), - Binop(OpLt), - Binop(OpGte), - Binop(OpLte), - Binop(OpEq), - Binop(OpNotEq) - ], compareOpPolicy); + Binop(OpGt), + Binop(OpLt), + Binop(OpGte), + Binop(OpLte), + Binop(OpEq), + Binop(OpNotEq) + ], compareOpPolicy); } function checkBitwiseOps(root:TokenTree) { checkTokens(root, [ - Binop(OpAnd), - Binop(OpOr), - Binop(OpXor), - Binop(OpShl), - Binop(OpShr), - Binop(OpUShr) - ], bitwiseOpPolicy); + Binop(OpAnd), + Binop(OpOr), + Binop(OpXor), + Binop(OpShl), + Binop(OpShr), + Binop(OpUShr) + ], bitwiseOpPolicy); } function checkBoolOps(root:TokenTree) { - checkTokens(root, [ - Binop(OpBoolAnd), - Binop(OpBoolOr) - ], boolOpPolicy); + checkTokens(root, [Binop(OpBoolAnd), Binop(OpBoolOr)], boolOpPolicy); } function checkIntervalOps(root:TokenTree) { @@ -253,48 +238,52 @@ class OperatorWhitespaceCheck extends WhitespaceCheckBase { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "assignOpPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "ternaryOpPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "arithmeticOpPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "unaryOpPolicy", - values: [INNER, NONE, IGNORE] - }, + return [ { - propertyName: "compareOpPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "bitwiseOpPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "boolOpPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "intervalOpPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "arrowPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "functionArgPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "assignOpPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "ternaryOpPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "arithmeticOpPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "unaryOpPolicy", + values: [INNER, NONE, IGNORE] + }, + { + propertyName: "compareOpPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "bitwiseOpPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "boolOpPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "intervalOpPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "arrowPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "functionArgPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/OperatorWrapCheck.hx b/src/checkstyle/checks/whitespace/OperatorWrapCheck.hx index 40ea3f05..90740ded 100644 --- a/src/checkstyle/checks/whitespace/OperatorWrapCheck.hx +++ b/src/checkstyle/checks/whitespace/OperatorWrapCheck.hx @@ -4,11 +4,10 @@ import checkstyle.checks.whitespace.WrapCheckBase.WrapCheckBaseOption; /** Checks line wrapping with operators. - **/ +**/ @name("OperatorWrap") @desc("Checks line wrapping with operators.") class OperatorWrapCheck extends WrapCheckBase { - public function new() { super(); tokens = [ @@ -102,12 +101,16 @@ class OperatorWrapCheck extends WrapCheckBase { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "option", - values: [WrapCheckBaseOption.EOL, WrapCheckBaseOption.NL] - }] - }]; + return [ + { + fixed: [], + properties: [ + { + propertyName: "option", + values: [WrapCheckBaseOption.EOL, WrapCheckBaseOption.NL] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/SeparatorWhitespaceCheck.hx b/src/checkstyle/checks/whitespace/SeparatorWhitespaceCheck.hx index 0c63e205..ca6c0266 100644 --- a/src/checkstyle/checks/whitespace/SeparatorWhitespaceCheck.hx +++ b/src/checkstyle/checks/whitespace/SeparatorWhitespaceCheck.hx @@ -4,11 +4,10 @@ import checkstyle.checks.whitespace.WhitespaceCheckBase.WhitespacePolicy; /** Checks that whitespace is present or absent around a separators. - **/ +**/ @name("SeparatorWhitespace") @desc("Checks that whitespace is present or absent around a separators.") class SeparatorWhitespaceCheck extends WhitespaceCheckBase { - /** policy for "." - around = enforce whitespace before and after operator @@ -16,7 +15,7 @@ class SeparatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var dotPolicy:WhitespacePolicy; /** @@ -26,7 +25,7 @@ class SeparatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var commaPolicy:WhitespacePolicy; /** @@ -36,7 +35,7 @@ class SeparatorWhitespaceCheck extends WhitespaceCheckBase { - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ + **/ public var semicolonPolicy:WhitespacePolicy; public function new() { @@ -57,7 +56,7 @@ class SeparatorWhitespaceCheck extends WhitespaceCheckBase { } override function violation(tok:TokenTree, policy:String) { - if (isWrapped(tok, cast (policy, WhitespacePolicy))) return; + if (isWrapped(tok, cast(policy, WhitespacePolicy))) return; logPos('SeparatorWhitespace policy "$policy" violated by "$tok"', tok.pos); } @@ -89,20 +88,24 @@ class SeparatorWhitespaceCheck extends WhitespaceCheckBase { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "dotPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, - { - propertyName: "commaPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }, + return [ { - propertyName: "semicolonPolicy", - values: [BEFORE, AFTER, AROUND, NONE, IGNORE] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "dotPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "commaPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + }, + { + propertyName: "semicolonPolicy", + values: [BEFORE, AFTER, AROUND, NONE, IGNORE] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/SeparatorWrapCheck.hx b/src/checkstyle/checks/whitespace/SeparatorWrapCheck.hx index 17756838..41d37228 100644 --- a/src/checkstyle/checks/whitespace/SeparatorWrapCheck.hx +++ b/src/checkstyle/checks/whitespace/SeparatorWrapCheck.hx @@ -4,16 +4,13 @@ import checkstyle.checks.whitespace.WrapCheckBase.WrapCheckBaseOption; /** Checks line wrapping with separators. - **/ +**/ @name("SeparatorWrap") @desc("Checks line wrapping with separators.") class SeparatorWrapCheck extends WrapCheckBase { - public function new() { super(); - tokens = [ - ",", - ]; + tokens = [","]; } override function actualRun() { @@ -27,12 +24,16 @@ class SeparatorWrapCheck extends WrapCheckBase { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "option", - values: [WrapCheckBaseOption.EOL, WrapCheckBaseOption.NL] - }] - }]; + return [ + { + fixed: [], + properties: [ + { + propertyName: "option", + values: [WrapCheckBaseOption.EOL, WrapCheckBaseOption.NL] + } + ] + } + ]; } } \ No newline at end of file diff --git a/src/checkstyle/checks/whitespace/SpacingCheck.hx b/src/checkstyle/checks/whitespace/SpacingCheck.hx index 49e9df7b..13b7da80 100644 --- a/src/checkstyle/checks/whitespace/SpacingCheck.hx +++ b/src/checkstyle/checks/whitespace/SpacingCheck.hx @@ -4,19 +4,18 @@ import haxe.macro.Printer; /** Spacing check on if, for, while, switch, try statements and around operators. - **/ +**/ @name("Spacing") @desc("Spacing check on if, for, while, switch, try statements and around operators.") class SpacingCheck extends Check { - /** require space around Binop operators ("+", "-", "/", etc.) - **/ + **/ public var spaceAroundBinop:Bool; /** enforce no space around Unop operators ("++", "--", "!", "-", "~") - **/ + **/ public var noSpaceAroundUnop:Bool; /** @@ -24,7 +23,7 @@ class SpacingCheck extends Check { - should = require space between statement and condition - shouldNot = no space should between statement and condition - any = ignored by space check - **/ + **/ public var spaceIfCondition:SpacingPolicy; /** @@ -32,7 +31,7 @@ class SpacingCheck extends Check { - should = require space between statement and condition - shouldNot = no space should between statement and condition - any = ignored by space check - **/ + **/ public var spaceForLoop:SpacingPolicy; /** @@ -40,7 +39,7 @@ class SpacingCheck extends Check { - should = require space between statement and condition - shouldNot = no space should between statement and condition - any = ignored by space check - **/ + **/ public var spaceWhileLoop:SpacingPolicy; /** @@ -48,7 +47,7 @@ class SpacingCheck extends Check { - should = require space between statement and condition - shouldNot = no space should between statement and condition - any = ignored by space check - **/ + **/ public var spaceSwitchCase:SpacingPolicy; /** @@ -56,12 +55,12 @@ class SpacingCheck extends Check { - should = require space between statement and condition - shouldNot = no space should between statement and condition - any = ignored by space check - **/ + **/ public var spaceCatch:SpacingPolicy; /** exclude range operator "..." from "spaceAroundBinop" - **/ + **/ public var ignoreRangeOperator:Bool; public function new() { @@ -79,13 +78,7 @@ class SpacingCheck extends Check { override function actualRun() { var root:TokenTree = checker.getTokenTree(); - var acceptableTokens:Array = root.filter([ - Kwd(KwdIf), - Kwd(KwdFor), - Kwd(KwdWhile), - Kwd(KwdSwitch), - Kwd(KwdCatch) - ], ALL); + var acceptableTokens:Array = root.filter([Kwd(KwdIf), Kwd(KwdFor), Kwd(KwdWhile), Kwd(KwdSwitch), Kwd(KwdCatch)], ALL); for (token in acceptableTokens) { var firstChild:TokenTree = token.getFirstChild(); @@ -156,45 +149,49 @@ class SpacingCheck extends Check { } override public function detectableInstances():DetectableInstances { - return [{ - fixed: [], - properties: [{ - propertyName: "spaceIfCondition", - values: [SHOULD, SHOULD_NOT, ANY] - }, - { - propertyName: "spaceForLoop", - values: [SHOULD, SHOULD_NOT, ANY] - }, - { - propertyName: "spaceWhileLoop", - values: [SHOULD, SHOULD_NOT, ANY] - }, - { - propertyName: "spaceWhileLoop", - values: [SHOULD, SHOULD_NOT, ANY] - }, - { - propertyName: "spaceSwitchCase", - values: [SHOULD, SHOULD_NOT, ANY] - }, + return [ { - propertyName: "spaceCatch", - values: [SHOULD, SHOULD_NOT, ANY] - }, - { - propertyName: "ignoreRangeOperator", - values: [true, false] - }, - { - propertyName: "spaceAroundBinop", - values: [true, false] - }, - { - propertyName: "noSpaceAroundUnop", - values: [true, false] - }] - }]; + fixed: [], + properties: [ + { + propertyName: "spaceIfCondition", + values: [SHOULD, SHOULD_NOT, ANY] + }, + { + propertyName: "spaceForLoop", + values: [SHOULD, SHOULD_NOT, ANY] + }, + { + propertyName: "spaceWhileLoop", + values: [SHOULD, SHOULD_NOT, ANY] + }, + { + propertyName: "spaceWhileLoop", + values: [SHOULD, SHOULD_NOT, ANY] + }, + { + propertyName: "spaceSwitchCase", + values: [SHOULD, SHOULD_NOT, ANY] + }, + { + propertyName: "spaceCatch", + values: [SHOULD, SHOULD_NOT, ANY] + }, + { + propertyName: "ignoreRangeOperator", + values: [true, false] + }, + { + propertyName: "spaceAroundBinop", + values: [true, false] + }, + { + propertyName: "noSpaceAroundUnop", + values: [true, false] + } + ] + } + ]; } } @@ -202,7 +199,7 @@ class SpacingCheck extends Check { - should = require space between statement and condition - shouldNot = no space should between statement and condition - any = ignored by space check - **/ +**/ @:enum abstract SpacingPolicy(String) { var SHOULD = "should"; diff --git a/src/checkstyle/checks/whitespace/TabForAligningCheck.hx b/src/checkstyle/checks/whitespace/TabForAligningCheck.hx index 49f67967..eb69cbdc 100644 --- a/src/checkstyle/checks/whitespace/TabForAligningCheck.hx +++ b/src/checkstyle/checks/whitespace/TabForAligningCheck.hx @@ -2,14 +2,13 @@ package checkstyle.checks.whitespace; /** Checks if there are any tabs in the middle of a line. - **/ +**/ @name("TabForAligning") @desc("Checks if there are any tabs in the middle of a line.") class TabForAligningCheck extends LineCheckBase { - /** ignore linex matching regex - **/ + **/ public var ignorePattern:String; public function new() { diff --git a/src/checkstyle/checks/whitespace/TrailingWhitespaceCheck.hx b/src/checkstyle/checks/whitespace/TrailingWhitespaceCheck.hx index f4be96fc..42fe52ca 100644 --- a/src/checkstyle/checks/whitespace/TrailingWhitespaceCheck.hx +++ b/src/checkstyle/checks/whitespace/TrailingWhitespaceCheck.hx @@ -2,11 +2,10 @@ package checkstyle.checks.whitespace; /** Checks if there are any trailing white spaces. - **/ +**/ @name("TrailingWhitespace") @desc("Checks if there are any trailing white spaces.") class TrailingWhitespaceCheck extends LineCheckBase { - public function new() { super(); severity = SeverityLevel.IGNORE; diff --git a/src/checkstyle/checks/whitespace/WhitespaceAfterCheck.hx b/src/checkstyle/checks/whitespace/WhitespaceAfterCheck.hx index e4fca679..2d9fe2ec 100644 --- a/src/checkstyle/checks/whitespace/WhitespaceAfterCheck.hx +++ b/src/checkstyle/checks/whitespace/WhitespaceAfterCheck.hx @@ -4,25 +4,21 @@ import tokentree.utils.TokenTreeCheckUtils; /** Checks for whitespace after a token. - **/ +**/ @name("WhitespaceAfter") @desc("Checks for whitespace after a token.") class WhitespaceAfterCheck extends Check { - /** supported list of tokens: ",", ";", "(", "[", "{", ":", ".", "=", "+", "-", "*", "/", "%", ">", "<", ">=", "<=", "==", "!=", "&", "|", "^", "&&", "||", "<<", ">>", ">>>", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", "|=", "&=", "^=", "...", "=>", "!", "++", "--", - **/ + **/ public var tokens:Array; public function new() { super(TOKEN); - tokens = [ - ",", - ";" - ]; + tokens = [",", ";"]; } function hasToken(token:String):Bool { diff --git a/src/checkstyle/checks/whitespace/WhitespaceAroundCheck.hx b/src/checkstyle/checks/whitespace/WhitespaceAroundCheck.hx index 1e63736f..bb2050cf 100644 --- a/src/checkstyle/checks/whitespace/WhitespaceAroundCheck.hx +++ b/src/checkstyle/checks/whitespace/WhitespaceAroundCheck.hx @@ -4,17 +4,16 @@ import tokentree.utils.TokenTreeCheckUtils; /** Checks that a token is surrounded by whitespace. - **/ +**/ @name("WhitespaceAround") @desc("Checks that a token is surrounded by whitespace.") class WhitespaceAroundCheck extends Check { - /** supported list of tokens: ",", ";", "(", ")", "[", "]", "{", "}", ":", ".", "=", "+", "-", "*", "/", "%", ">", "<", ">=", "<=", "==", "!=", "&", "|", "^", "&&", "||", "<<", ">>", ">>>", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", "|=", "&=", "^=", "...", "=>", "!", "++", "--", - **/ + **/ public var tokens:Array; public function new() { diff --git a/src/checkstyle/checks/whitespace/WhitespaceCheckBase.hx b/src/checkstyle/checks/whitespace/WhitespaceCheckBase.hx index 522e04f7..6098573b 100644 --- a/src/checkstyle/checks/whitespace/WhitespaceCheckBase.hx +++ b/src/checkstyle/checks/whitespace/WhitespaceCheckBase.hx @@ -4,10 +4,9 @@ import tokentree.utils.TokenTreeCheckUtils; /** base class for OperatorWhitespace and SeparatorWhitespace - **/ +**/ @ignore("base class for OperatorWhitespace and SeparatorWhitespace") class WhitespaceCheckBase extends Check { - public function new() { super(TOKEN); @@ -95,7 +94,7 @@ typedef WhitespacePolicyCheck = Bool -> Bool -> Void; - after = enforce no whitespace before and whitespace after operator - none = enforce no whitespace before and after operator - ignore = skip checks - **/ +**/ @:enum abstract WhitespacePolicy(String) { var BEFORE = "before"; @@ -110,7 +109,7 @@ abstract WhitespacePolicy(String) { - inner = enforce whitespace between unary operator and operand - none = enforce no whitespace between unary operator and operand - ignore = skip checks - **/ +**/ @:enum abstract WhitespaceUnaryPolicy(String) { var INNER = "inner"; diff --git a/src/checkstyle/checks/whitespace/WrapCheckBase.hx b/src/checkstyle/checks/whitespace/WrapCheckBase.hx index da21ea56..704e2f7f 100644 --- a/src/checkstyle/checks/whitespace/WrapCheckBase.hx +++ b/src/checkstyle/checks/whitespace/WrapCheckBase.hx @@ -4,20 +4,19 @@ import tokentree.utils.TokenTreeCheckUtils; /** base class for OperatorWrap and SeparatorWrap - **/ +**/ @ignore("base class for OperatorWrap and SeparatorWrap") class WrapCheckBase extends Check { - /** list mof wrapping tokens - **/ + **/ public var tokens:Array; /** policy for wrapping token - eol = wrapping token should be at end of line - nl = wrapping token should start a new line - **/ + **/ public var option:WrapCheckBaseOption; public function new() { @@ -67,7 +66,7 @@ class WrapCheckBase extends Check { policy for wrapping token - eol = wrapping token should be at end of line - nl = wrapping token should start a new line - **/ +**/ @:enum abstract WrapCheckBaseOption(String) { var EOL = "eol"; diff --git a/src/checkstyle/config/Config.hx b/src/checkstyle/config/Config.hx index 3d9d9c57..4696187a 100644 --- a/src/checkstyle/config/Config.hx +++ b/src/checkstyle/config/Config.hx @@ -8,32 +8,36 @@ typedef Config = { Checks and excludes from both master and current configuration file form the final runtime configuration. There is no shadowing or overwriting checks or excludes, Checkstyle runs every check regardless where it comes from. A master configuration file can have its own "extendsConfigPath" entry. Checkstyle will walk up the chain as long as it does not cycle. - **/ + **/ @:optional var extendsConfigPath:String; + /** Each check has a builtin severity level. Setting "defaultSeverity" applies its value to all checks that have no explicity "severity" field in their configuration @see checkstyle.SeverityLevel - **/ + **/ @:optional var defaultSeverity:SeverityLevel; + /** defines that are always added - **/ + **/ @:optional var baseDefines:Array; - // + /** different define combinations to use (on top of "baseDefines") - **/ + **/ @:optional var defineCombinations:Array>; + /** Sets the number of checker threads, valid range is 1-15 - **/ + **/ @:optional var numberOfCheckerThreads:Int; @:optional var checks:Array; @:optional var exclude:ExcludeConfig; + /** version number - **/ + **/ @:optional var version:Int; } \ No newline at end of file diff --git a/src/checkstyle/config/ConfigParser.hx b/src/checkstyle/config/ConfigParser.hx index 16bddcfa..fe066e19 100644 --- a/src/checkstyle/config/ConfigParser.hx +++ b/src/checkstyle/config/ConfigParser.hx @@ -11,7 +11,6 @@ import sys.io.File; import haxe.io.Path; class ConfigParser { - public var paths:Array; public var excludesMap:Map>; public var allExcludes:Array; @@ -180,7 +179,7 @@ class ConfigParser { } catch (e:Any) { var message = 'Failed to configure $prop setting for ${check.getModuleName()}: '; - message += (Std.is(e, Error) ? (e:Error).message : Std.string(e)); + message += (Std.is(e, Error) ? (e : Error).message : Std.string(e)); failWith(message); } } @@ -245,7 +244,8 @@ class ConfigParser { function failWith(msg:String) { switch (validateMode) { - case STRICT: failWithCallback(msg); + case STRICT: + failWithCallback(msg); case RELAXED: } } diff --git a/src/checkstyle/config/ExcludeConfig.hx b/src/checkstyle/config/ExcludeConfig.hx index 931ef4ed..c10b77c8 100644 --- a/src/checkstyle/config/ExcludeConfig.hx +++ b/src/checkstyle/config/ExcludeConfig.hx @@ -2,16 +2,18 @@ package checkstyle.config; /** defines filters to exclude folders, types or files from all or specific checks - **/ +**/ typedef ExcludeConfig = { @:optional var path:ExcludePath; + /** exclude matching files from all checks - **/ + **/ @:optional var all:ExcludeFilterList; + /** version number - **/ + **/ @:optional var version:Int; } @@ -25,5 +27,5 @@ typedef ExcludeConfig = { - ":" = only matches a specific line number - valid line number start at 1 - ":-" = matches line numbers from to (including both) - ":" = matches any line or block that has name (Haxe keywords currently unsupported) - **/ +**/ typedef ExcludeFilterList = Array; \ No newline at end of file diff --git a/src/checkstyle/config/ExcludeManager.hx b/src/checkstyle/config/ExcludeManager.hx index 9f450cc3..e046795d 100644 --- a/src/checkstyle/config/ExcludeManager.hx +++ b/src/checkstyle/config/ExcludeManager.hx @@ -36,15 +36,15 @@ class ExcludeManager { return IDENTIFIER(filter, range); } - public static function isExcludedFromAll(fileName: String):Bool { + public static function isExcludedFromAll(fileName:String):Bool { return INSTANCE.checkFileExcluded(fileName, INSTANCE.globalExclude); } - public static function isExcludedFromCheck(fileName: String, checkName:String):Bool { + public static function isExcludedFromCheck(fileName:String, checkName:String):Bool { return INSTANCE.checkFileExcluded(fileName, INSTANCE.excludeMap.get(checkName)); } - function checkFileExcluded(fileName: String, list:Array):Bool { + function checkFileExcluded(fileName:String, list:Array):Bool { if (list == null) return false; for (exclude in list) { if (matchFullExlude(fileName, exclude)) { @@ -56,10 +56,14 @@ class ExcludeManager { function matchFullExlude(fileName:String, exclude:ExcludeDefinition):Bool { switch (exclude) { - case FULL(filter): return filterFileName(fileName, filter); - case LINE(filter, line): return false; - case RANGE(filter, lineStart, lineEnd): return false; - case IDENTIFIER(filter, name): return false; + case FULL(filter): + return filterFileName(fileName, filter); + case LINE(filter, line): + return false; + case RANGE(filter, lineStart, lineEnd): + return false; + case IDENTIFIER(filter, name): + return false; } } @@ -81,7 +85,8 @@ class ExcludeManager { if (list != null) { for (exclude in list) { switch (exclude) { - case FULL(filter): continue; + case FULL(filter): + continue; case LINE(filter, line): if (!filterFileName(checker.file.name, filter)) continue; posExcludes.push(makeLinesExcludeRange(checker, checkName, line - 1, line)); @@ -103,7 +108,8 @@ class ExcludeManager { for (exclude in globalExclude) { switch (exclude) { - case FULL(filter): continue; + case FULL(filter): + continue; case LINE(filter, line): if (!filterFileName(checker.file.name, filter)) continue; for (check in checker.checks) { @@ -143,7 +149,8 @@ class ExcludeManager { if (!StringTools.startsWith(name, "checkstyle:")) return SKIP_SUBTREE; checkNames.push(name.substr(11)); return SKIP_SUBTREE; - default: return GO_DEEPER; + default: + return GO_DEEPER; } }); for (name in checkNames) { @@ -157,7 +164,7 @@ class ExcludeManager { var map:Map> = new Map>(); for (range in list) { var rangeList:Array = map.get(range.checkName); - if (rangeList == null ) { + if (rangeList == null) { rangeList = []; } rangeList.push(range); diff --git a/src/checkstyle/config/ExcludePath.hx b/src/checkstyle/config/ExcludePath.hx index dc574d63..2b4c52c7 100644 --- a/src/checkstyle/config/ExcludePath.hx +++ b/src/checkstyle/config/ExcludePath.hx @@ -4,7 +4,7 @@ package checkstyle.config; filters excludes relative to - RELATIVE_TO_PROJECT = use project root - RELATIVE_TO_SOURCE = use path(s) specified via "-s " command line switches - **/ +**/ @:enum abstract ExcludePath(String) { var RELATIVE_TO_PROJECT = "RELATIVE_TO_PROJECT"; diff --git a/src/checkstyle/detect/DetectCodingStyle.hx b/src/checkstyle/detect/DetectCodingStyle.hx index 30bc1092..fc14ad45 100644 --- a/src/checkstyle/detect/DetectCodingStyle.hx +++ b/src/checkstyle/detect/DetectCodingStyle.hx @@ -8,7 +8,6 @@ import checkstyle.reporter.ReporterManager; import haxe.ds.ArraySort; class DetectCodingStyle { - public static function detectCodingStyle(checks:Array, fileList:Array):Array { var detectedChecks:Array = []; ArraySort.sort(checks, ConfigUtils.checkSort); diff --git a/src/checkstyle/detect/DetectionReporter.hx b/src/checkstyle/detect/DetectionReporter.hx index d7981a3b..79510e02 100644 --- a/src/checkstyle/detect/DetectionReporter.hx +++ b/src/checkstyle/detect/DetectionReporter.hx @@ -3,7 +3,6 @@ package checkstyle.detect; import checkstyle.reporter.IReporter; class DetectionReporter implements IReporter { - public var messageCount:Int; public function new() { diff --git a/src/checkstyle/errors/Error.hx b/src/checkstyle/errors/Error.hx index d29fe499..e1603907 100644 --- a/src/checkstyle/errors/Error.hx +++ b/src/checkstyle/errors/Error.hx @@ -1,7 +1,7 @@ package checkstyle.errors; class Error { - public var message (default, null):String; + public var message(default, null):String; public function new(message:String) { this.message = message; diff --git a/src/checkstyle/import.hx b/src/checkstyle/import.hx index ead69622..6e9082ee 100644 --- a/src/checkstyle/import.hx +++ b/src/checkstyle/import.hx @@ -1,16 +1,12 @@ package checkstyle; import haxe.io.Bytes; - import haxe.macro.Expr; import haxeparser.Data; - import checkstyle.Checker.LinePos; import checkstyle.SeverityLevel; import checkstyle.detect.DetectableInstances; - import checkstyle.utils.ErrorUtils; - import tokentree.TokenTree; import tokentree.TokenTreeAccessHelper; import tokentree.utils.TokenTreeCheckUtils; diff --git a/src/checkstyle/reporter/BaseReporter.hx b/src/checkstyle/reporter/BaseReporter.hx index 96a314fc..13ff980b 100644 --- a/src/checkstyle/reporter/BaseReporter.hx +++ b/src/checkstyle/reporter/BaseReporter.hx @@ -6,12 +6,10 @@ import sys.io.File; import sys.io.FileOutput; class BaseReporter implements IReporter { - var errors:Int; var warnings:Int; var infos:Int; var total:Int; - var report:StringBuf; var file:FileOutput; var numFiles:Int; @@ -55,6 +53,7 @@ class BaseReporter implements IReporter { total = errors + warnings + infos; if (total > 0) { + // @formatter:off Sys.println( styleText("\nTotal Issues: " + total + " (", Style.BOLD) + styleText("Errors: " + errors, Style.RED) + @@ -63,6 +62,7 @@ class BaseReporter implements IReporter { styleText(", ", Style.BOLD) + styleText("Infos: " + infos, Style.BLUE) + styleText(")", Style.BOLD)); + // @formatter:on } else Sys.println(styleText("No issues found.", Style.BOLD)); } diff --git a/src/checkstyle/reporter/CodeClimateReporter.hx b/src/checkstyle/reporter/CodeClimateReporter.hx index b3f76bc2..f0d3b5d7 100644 --- a/src/checkstyle/reporter/CodeClimateReporter.hx +++ b/src/checkstyle/reporter/CodeClimateReporter.hx @@ -5,7 +5,6 @@ import haxe.Json; using StringTools; class CodeClimateReporter extends BaseReporter { - static inline var INFO:String = "info"; static inline var NORMAL:String = "normal"; static inline var CRITICAL:String = "critical"; @@ -29,7 +28,7 @@ class CodeClimateReporter extends BaseReporter { severity: getSeverity(m.severity), categories: m.categories, remediation_points: m.points * REMEDIATION_BASE, - location:{ + location: { path: file, positions: { begin: { diff --git a/src/checkstyle/reporter/ExitCodeReporter.hx b/src/checkstyle/reporter/ExitCodeReporter.hx index 5e17f73e..b3055bcd 100644 --- a/src/checkstyle/reporter/ExitCodeReporter.hx +++ b/src/checkstyle/reporter/ExitCodeReporter.hx @@ -1,7 +1,6 @@ package checkstyle.reporter; class ExitCodeReporter implements IReporter { - var failCheckCount:Int; public function new() { diff --git a/src/checkstyle/reporter/IReporter.hx b/src/checkstyle/reporter/IReporter.hx index 0f2f50d5..d5ef56ae 100644 --- a/src/checkstyle/reporter/IReporter.hx +++ b/src/checkstyle/reporter/IReporter.hx @@ -1,19 +1,14 @@ package checkstyle.reporter; interface IReporter { - // Before any file checked function start():Void; - // After all files checked function finish():Void; - // Before file checked function fileStart(f:CheckFile):Void; - // After file checked function fileFinish(f:CheckFile):Void; - // When issue found function addMessage(m:CheckMessage):Void; } \ No newline at end of file diff --git a/src/checkstyle/reporter/JSONReporter.hx b/src/checkstyle/reporter/JSONReporter.hx index aa39c06a..03cee904 100644 --- a/src/checkstyle/reporter/JSONReporter.hx +++ b/src/checkstyle/reporter/JSONReporter.hx @@ -3,7 +3,6 @@ package checkstyle.reporter; import haxe.Json; class JSONReporter extends BaseReporter { - var jsonReport:GlobalReport; var fileReport:FileReport; @@ -35,9 +34,12 @@ class JSONReporter extends BaseReporter { fileReport.messages.push(reportMessage); switch (m.severity) { - case ERROR: errors++; - case WARNING: warnings++; - case INFO: infos++; + case ERROR: + errors++; + case WARNING: + warnings++; + case INFO: + infos++; default: } diff --git a/src/checkstyle/reporter/ProgressReporter.hx b/src/checkstyle/reporter/ProgressReporter.hx index 47e902f1..4ed7c490 100644 --- a/src/checkstyle/reporter/ProgressReporter.hx +++ b/src/checkstyle/reporter/ProgressReporter.hx @@ -1,7 +1,6 @@ package checkstyle.reporter; class ProgressReporter implements IReporter { - var lineLength:Int; var numFiles:Int; diff --git a/src/checkstyle/reporter/ReporterManager.hx b/src/checkstyle/reporter/ReporterManager.hx index 3a267183..7eaae09d 100644 --- a/src/checkstyle/reporter/ReporterManager.hx +++ b/src/checkstyle/reporter/ReporterManager.hx @@ -9,9 +9,7 @@ import cpp.hl.Mutex; #else import checkstyle.utils.Mutex; #end - import checkstyle.CheckMessage; - import checkstyle.checks.Category; class ReporterManager { @@ -21,7 +19,7 @@ class ReporterManager { var reporters:Array; var lock:Mutex; - function new () { + function new() { #if (debug || unittest) SHOW_PARSE_ERRORS = true; #end @@ -88,6 +86,7 @@ class ReporterManager { } function areMessagesSame(message1:CheckMessage, message2:CheckMessage):Bool { + // @formatter:off return ( message1.fileName == message2.fileName && message1.message == message2.message && @@ -99,22 +98,23 @@ class ReporterManager { message1.severity == message2.severity && message1.moduleName == message2.moduleName ); + // @formatter:on } function getErrorMessage(e:Any, fileName:String, step:String):CheckMessage { return { - fileName:fileName, - startLine:1, - endLine:1, - startColumn:0, - endColumn:0, - severity:ERROR, - moduleName:"Checker", - categories:[Category.STYLE], - points:1, - desc:"", - code:'$e', - message:'$step failed: $e\nPlease file a github issue at https://github.com/HaxeCheckstyle/haxe-checkstyle/issues' + fileName: fileName, + startLine: 1, + endLine: 1, + startColumn: 0, + endColumn: 0, + severity: ERROR, + moduleName: "Checker", + categories: [Category.STYLE], + points: 1, + desc: "", + code: '$e', + message: '$step failed: $e\nPlease file a github issue at https://github.com/HaxeCheckstyle/haxe-checkstyle/issues' }; } } \ No newline at end of file diff --git a/src/checkstyle/reporter/TextReporter.hx b/src/checkstyle/reporter/TextReporter.hx index 7725c44f..09119a56 100644 --- a/src/checkstyle/reporter/TextReporter.hx +++ b/src/checkstyle/reporter/TextReporter.hx @@ -3,14 +3,15 @@ package checkstyle.reporter; import haxe.io.Output; class TextReporter extends BaseReporter { - override public function addMessage(m:CheckMessage) { var sb:StringBuf = getMessage(m); var output:Output = Sys.stderr(); switch (m.severity) { - case ERROR: errors++; - case WARNING: warnings++; + case ERROR: + errors++; + case WARNING: + warnings++; case INFO: infos++; output = Sys.stdout(); diff --git a/src/checkstyle/reporter/XMLReporter.hx b/src/checkstyle/reporter/XMLReporter.hx index f1d0d210..04f42dcc 100644 --- a/src/checkstyle/reporter/XMLReporter.hx +++ b/src/checkstyle/reporter/XMLReporter.hx @@ -1,9 +1,7 @@ package checkstyle.reporter; class XMLReporter extends BaseReporter { - var style:String; - var messageCache:Map>; /** @@ -18,7 +16,6 @@ class XMLReporter extends BaseReporter { "'" => "'", "/" => "/" ]; - static var ENTITY_RE:EReg = ~/[&<>"'\/]/g; public function new(numFiles:Int, checkCount:Int, usedCheckCount:Int, path:String, s:String, ns:Bool) { @@ -104,9 +101,12 @@ class XMLReporter extends BaseReporter { sb.add("\"/>\n"); switch (m.severity) { - case ERROR: errors++; - case WARNING: warnings++; - case INFO: infos++; + case ERROR: + errors++; + case WARNING: + warnings++; + case INFO: + infos++; default: } diff --git a/src/checkstyle/utils/ArrayUtils.hx b/src/checkstyle/utils/ArrayUtils.hx index eec7dd42..96b9f259 100644 --- a/src/checkstyle/utils/ArrayUtils.hx +++ b/src/checkstyle/utils/ArrayUtils.hx @@ -3,7 +3,6 @@ package checkstyle.utils; import haxe.ds.ArraySort; class ArrayUtils { - public static inline function contains(a:Array, el:T):Bool { return a.indexOf(el) != -1; } diff --git a/src/checkstyle/utils/ComplexTypeUtils.hx b/src/checkstyle/utils/ComplexTypeUtils.hx index 60df5913..1c8bc553 100644 --- a/src/checkstyle/utils/ComplexTypeUtils.hx +++ b/src/checkstyle/utils/ComplexTypeUtils.hx @@ -1,13 +1,12 @@ package checkstyle.utils; class ComplexTypeUtils { - - public static function walkFile(file:{ pack:Array, decls:Array }, cb:ComplexTypeCallback) { + public static function walkFile(file:{pack:Array, decls:Array}, cb:ComplexTypeCallback) { for (decl in file.decls) walkTypeDecl(decl, cb); } public static function walkTypeDecl(td:TypeDecl, cb:ComplexTypeCallback) { - switch (td.decl){ + switch (td.decl) { case EClass(d): walkClass(d, td.pos, cb); case EEnum(d): @@ -36,7 +35,8 @@ class ComplexTypeUtils { walkCommonDefinition(d, pos, cb); for (f in d.flags) { switch (f) { - case HExtends(t) | HImplements(t): walkTypePath(t, d.name, pos, cb); + case HExtends(t) | HImplements(t): + walkTypePath(t, d.name, pos, cb); default: } } @@ -57,7 +57,8 @@ class ComplexTypeUtils { walkCommonDefinition(d, pos, cb); for (f in d.flags) { switch (f) { - case AFromType(ct) | AToType(ct) | AIsType(ct): walkComplexType(ct, f.getName(), pos, cb); + case AFromType(ct) | AToType(ct) | AIsType(ct): + walkComplexType(ct, f.getName(), pos, cb); default: } } @@ -74,9 +75,11 @@ class ComplexTypeUtils { public static function walkTypePath(tp:TypePath, name:String, pos:Position, cb:ComplexTypeCallback) { if (tp.params != null) { for (p in tp.params) { - switch (p){ - case TPType(t): walkComplexType(t, name, pos, cb); - case TPExpr(e): walkExpr(e, cb); + switch (p) { + case TPType(t): + walkComplexType(t, name, pos, cb); + case TPExpr(e): + walkExpr(e, cb); } } } @@ -114,7 +117,7 @@ class ComplexTypeUtils { } public static function walkField(f:Field, cb:ComplexTypeCallback) { - switch (f.kind){ + switch (f.kind) { case FVar(t, e): if (t != null) walkComplexType(t, f.name, f.pos, cb); if (e != null) walkExpr(e, cb); @@ -129,8 +132,9 @@ class ComplexTypeUtils { public static function walkComplexType(t:ComplexType, name:String, pos:Position, cb:ComplexTypeCallback) { cb(t, name, pos); if (t == null) return; - switch (t){ - case TPath(p): walkTypePath(p, name, pos, cb); + switch (t) { + case TPath(p): + walkTypePath(p, name, pos, cb); case TFunction(args, ret): for (a in args) walkComplexType(a, name, pos, cb); walkComplexType(ret, name, pos, cb); @@ -153,50 +157,82 @@ class ComplexTypeUtils { } public static function walkExpr(e:Expr, cb:ComplexTypeCallback) { - switch (e.expr){ + switch (e.expr) { case EConst(c): - case EArray(e1, e2): walkExpr(e1, cb); walkExpr(e2, cb); - case EBinop(op, e1, e2): walkExpr(e1, cb); walkExpr(e2, cb); - case EField(e, field): walkExpr(e, cb); - case EParenthesis(e): walkExpr(e, cb); - case EObjectDecl(fields): for (f in fields) walkExpr(f.expr, cb); - case EArrayDecl(values): for (v in values) walkExpr(v, cb); - case ECall(e, params): walkExpr(e, cb); + case EArray(e1, e2): + walkExpr(e1, cb); + walkExpr(e2, cb); + case EBinop(op, e1, e2): + walkExpr(e1, cb); + walkExpr(e2, cb); + case EField(e, field): + walkExpr(e, cb); + case EParenthesis(e): + walkExpr(e, cb); + case EObjectDecl(fields): + for (f in fields) walkExpr(f.expr, cb); + case EArrayDecl(values): + for (v in values) walkExpr(v, cb); + case ECall(e, params): + walkExpr(e, cb); for (p in params) walkExpr(p, cb); - case ENew(t, params): walkTypePath(t, "", e.pos, cb); + case ENew(t, params): + walkTypePath(t, "", e.pos, cb); for (p in params) walkExpr(p, cb); - case EUnop(op, postFix, e): walkExpr(e, cb); - case EVars(vars): for (v in vars) walkVar(v, e.pos, cb); - case EFunction(name, f): walkFunction(f, name, e.pos, cb); - case EBlock(exprs): for (e in exprs) walkExpr(e, cb); - case EFor(it, expr): walkExpr(it, cb); walkExpr(expr, cb); + case EUnop(op, postFix, e): + walkExpr(e, cb); + case EVars(vars): + for (v in vars) walkVar(v, e.pos, cb); + case EFunction(name, f): + walkFunction(f, name, e.pos, cb); + case EBlock(exprs): + for (e in exprs) walkExpr(e, cb); + case EFor(it, expr): + walkExpr(it, cb); + walkExpr(expr, cb); #if (haxe_ver < 4.0) - case EIn(e1, e2): walkExpr(e1, cb); walkExpr(e2, cb); + case EIn(e1, e2): + walkExpr(e1, cb); + walkExpr(e2, cb); #end - case EIf(econd, eif, eelse): walkExpr(econd, cb); + case EIf(econd, eif, eelse): + walkExpr(econd, cb); walkExpr(eif, cb); if (eelse != null) walkExpr(eelse, cb); - case EWhile(econd, e, normalWhile): walkExpr(econd, cb); walkExpr(e, cb); - case ESwitch(e, cases, edef): walkExpr(e, cb); + case EWhile(econd, e, normalWhile): + walkExpr(econd, cb); + walkExpr(e, cb); + case ESwitch(e, cases, edef): + walkExpr(e, cb); for (c in cases) walkCase(c, cb); if (edef != null && edef.expr != null) walkExpr(edef, cb); - case ETry(e, catches): walkExpr(e, cb); + case ETry(e, catches): + walkExpr(e, cb); for (c in catches) walkCatch(c, cb); - case EReturn(e): if (e != null) walkExpr(e, cb); + case EReturn(e): + if (e != null) walkExpr(e, cb); case EBreak: case EContinue: - case EUntyped(e): walkExpr(e, cb); - case EThrow(e): walkExpr(e, cb); - case ECast(e, t): walkExpr(e, cb); + case EUntyped(e): + walkExpr(e, cb); + case EThrow(e): + walkExpr(e, cb); + case ECast(e, t): + walkExpr(e, cb); if (t != null) walkComplexType(t, "", e.pos, cb); - case EDisplay(e, displayKind): walkExpr(e, cb); - case EDisplayNew(t): walkTypePath(t, t.name, e.pos, cb); - case ETernary(econd, eif, eelse): walkExpr(econd, cb); + case EDisplay(e, displayKind): + walkExpr(e, cb); + case EDisplayNew(t): + walkTypePath(t, t.name, e.pos, cb); + case ETernary(econd, eif, eelse): + walkExpr(econd, cb); walkExpr(eif, cb); walkExpr(eelse, cb); - case ECheckType(e, t): walkExpr(e, cb); + case ECheckType(e, t): + walkExpr(e, cb); walkComplexType(t, "", e.pos, cb); - case EMeta(s, e): if (s.params != null) for (mp in s.params) walkExpr(mp, cb); + case EMeta(s, e): + if (s.params != null) for (mp in s.params) walkExpr(mp, cb); walkExpr(e, cb); } } diff --git a/src/checkstyle/utils/ConfigUtils.hx b/src/checkstyle/utils/ConfigUtils.hx index 25b9faa3..5702f337 100644 --- a/src/checkstyle/utils/ConfigUtils.hx +++ b/src/checkstyle/utils/ConfigUtils.hx @@ -5,13 +5,11 @@ import checkstyle.ChecksInfo.CheckInfo; import checkstyle.config.Config; import checkstyle.config.CheckConfig; import checkstyle.checks.Check; - import haxe.Json; import haxe.ds.ArraySort; import sys.io.File; class ConfigUtils { - public static function getEmptyConfig():Config { return { defaultSeverity: SeverityLevel.INFO, @@ -70,11 +68,25 @@ class ConfigUtils { public static function makeCheckConfig(check:Check):CheckConfig { var propsNotAllowed:Array = [ - "moduleName", "severity", "type", "categories", - "points", "desc", "currentState", "skipOverStringStart", - "commentStartRE", "commentBlockEndRE", "stringStartRE", - "stringInterpolatedEndRE", "stringLiteralEndRE", "formatRE", - "skipOverInitialQuote", "messages", "checker", "placemap", "metaName" + "moduleName", + "severity", + "type", + "categories", + "points", + "desc", + "currentState", + "skipOverStringStart", + "commentStartRE", + "commentBlockEndRE", + "stringStartRE", + "stringInterpolatedEndRE", + "stringLiteralEndRE", + "formatRE", + "skipOverInitialQuote", + "messages", + "checker", + "placemap", + "metaName" ]; var checkConfig:CheckConfig = { type: check.getModuleName(), diff --git a/src/checkstyle/utils/ErrorUtils.hx b/src/checkstyle/utils/ErrorUtils.hx index b16a1bff..a27d7277 100644 --- a/src/checkstyle/utils/ErrorUtils.hx +++ b/src/checkstyle/utils/ErrorUtils.hx @@ -3,7 +3,6 @@ package checkstyle.utils; #if debug import haxe.CallStack; #end - import checkstyle.reporter.ReporterManager; class ErrorUtils { diff --git a/src/checkstyle/utils/ExprUtils.hx b/src/checkstyle/utils/ExprUtils.hx index 3b545f3b..c818af17 100644 --- a/src/checkstyle/utils/ExprUtils.hx +++ b/src/checkstyle/utils/ExprUtils.hx @@ -1,13 +1,12 @@ package checkstyle.utils; class ExprUtils { - - public static function walkFile(file:{ pack:Array, decls:Array }, cb:Expr -> Void) { + public static function walkFile(file:{pack:Array, decls:Array}, cb:Expr -> Void) { for (decl in file.decls) walkTypeDecl(decl, cb); } public static function walkTypeDecl(td:TypeDecl, cb:Expr -> Void) { - switch (td.decl){ + switch (td.decl) { case EClass(d): walkClass(d, cb); case EEnum(d): @@ -36,7 +35,8 @@ class ExprUtils { walkCommonDefinition(d, cb); for (f in d.flags) { switch (f) { - case HExtends(t) | HImplements(t): walkTypePath(t, cb); + case HExtends(t) | HImplements(t): + walkTypePath(t, cb); default: } } @@ -57,7 +57,8 @@ class ExprUtils { walkCommonDefinition(d, cb); for (f in d.flags) { switch (f) { - case AFromType(ct) | AToType(ct) | AIsType(ct): walkComplexType(ct, cb); + case AFromType(ct) | AToType(ct) | AIsType(ct): + walkComplexType(ct, cb); default: } } @@ -74,9 +75,11 @@ class ExprUtils { public static function walkTypePath(tp:TypePath, cb:Expr -> Void) { if (tp.params != null) { for (p in tp.params) { - switch (p){ - case TPType(t): walkComplexType(t, cb); - case TPExpr(e): walkExpr(e, cb); + switch (p) { + case TPType(t): + walkComplexType(t, cb); + case TPExpr(e): + walkExpr(e, cb); } } } @@ -114,7 +117,7 @@ class ExprUtils { } public static function walkField(f:Field, cb:Expr -> Void) { - switch (f.kind){ + switch (f.kind) { case FVar(t, e): if (t != null) walkComplexType(t, cb); if (e != null) walkExpr(e, cb); @@ -128,8 +131,9 @@ class ExprUtils { public static function walkComplexType(t:ComplexType, cb:Expr -> Void) { if (t == null) return; - switch (t){ - case TPath(p): walkTypePath(p, cb); + switch (t) { + case TPath(p): + walkTypePath(p, cb); case TFunction(args, ret): for (a in args) walkComplexType(a, cb); walkComplexType(ret, cb); @@ -153,48 +157,79 @@ class ExprUtils { public static function walkExpr(e:Expr, cb:Expr -> Void) { cb(e); - switch (e.expr){ + switch (e.expr) { case EConst(c): - case EArray(e1, e2): walkExpr(e1, cb); walkExpr(e2, cb); - case EBinop(op, e1, e2): walkExpr(e1, cb); walkExpr(e2, cb); - case EField(e, field): walkExpr(e, cb); - case EParenthesis(e): walkExpr(e, cb); - case EObjectDecl(fields): for (f in fields) walkExpr(f.expr, cb); - case EArrayDecl(values): for (v in values) walkExpr(v, cb); - case ECall(e, params): walkExpr(e, cb); + case EArray(e1, e2): + walkExpr(e1, cb); + walkExpr(e2, cb); + case EBinop(op, e1, e2): + walkExpr(e1, cb); + walkExpr(e2, cb); + case EField(e, field): + walkExpr(e, cb); + case EParenthesis(e): + walkExpr(e, cb); + case EObjectDecl(fields): + for (f in fields) walkExpr(f.expr, cb); + case EArrayDecl(values): + for (v in values) walkExpr(v, cb); + case ECall(e, params): + walkExpr(e, cb); for (p in params) walkExpr(p, cb); - case ENew(t, params): walkTypePath(t, cb); + case ENew(t, params): + walkTypePath(t, cb); for (p in params) walkExpr(p, cb); - case EUnop(op, postFix, e): walkExpr(e, cb); - case EVars(vars): for (v in vars) walkVar(v, cb); - case EFunction(name, f): walkFunction(f, cb); - case EBlock(exprs): for (e in exprs) walkExpr(e, cb); - case EFor(it, expr): walkExpr(it, cb); walkExpr(expr, cb); + case EUnop(op, postFix, e): + walkExpr(e, cb); + case EVars(vars): + for (v in vars) walkVar(v, cb); + case EFunction(name, f): + walkFunction(f, cb); + case EBlock(exprs): + for (e in exprs) walkExpr(e, cb); + case EFor(it, expr): + walkExpr(it, cb); + walkExpr(expr, cb); #if (haxe_ver < 4.0) - case EIn(e1, e2): walkExpr(e1, cb); walkExpr(e2, cb); + case EIn(e1, e2): + walkExpr(e1, cb); + walkExpr(e2, cb); #end - case EIf(econd, eif, eelse): walkExpr(econd, cb); + case EIf(econd, eif, eelse): + walkExpr(econd, cb); walkExpr(eif, cb); if (eelse != null) walkExpr(eelse, cb); - case EWhile(econd, e, normalWhile): walkExpr(econd, cb); walkExpr(e, cb); - case ESwitch(e, cases, edef): walkExpr(e, cb); + case EWhile(econd, e, normalWhile): + walkExpr(econd, cb); + walkExpr(e, cb); + case ESwitch(e, cases, edef): + walkExpr(e, cb); for (c in cases) walkCase(c, cb); if (edef != null && edef.expr != null) walkExpr(edef, cb); - case ETry(e, catches): walkExpr(e, cb); + case ETry(e, catches): + walkExpr(e, cb); for (c in catches) walkCatch(c, cb); - case EReturn(e): if (e != null) walkExpr(e, cb); + case EReturn(e): + if (e != null) walkExpr(e, cb); case EBreak: case EContinue: - case EUntyped(e): walkExpr(e, cb); - case EThrow(e): walkExpr(e, cb); - case ECast(e, t): walkExpr(e, cb); + case EUntyped(e): + walkExpr(e, cb); + case EThrow(e): + walkExpr(e, cb); + case ECast(e, t): + walkExpr(e, cb); if (t != null) walkComplexType(t, cb); - case EDisplay(e, displayKind): walkExpr(e, cb); - case EDisplayNew(t): walkTypePath(t, cb); - case ETernary(econd, eif, eelse): walkExpr(econd, cb); + case EDisplay(e, displayKind): + walkExpr(e, cb); + case EDisplayNew(t): + walkTypePath(t, cb); + case ETernary(econd, eif, eelse): + walkExpr(econd, cb); walkExpr(eif, cb); walkExpr(eelse, cb); - case ECheckType(e, t): walkExpr(e, cb); + case ECheckType(e, t): + walkExpr(e, cb); walkComplexType(t, cb); case EMeta(s, e): if (s.params != null) for (mp in s.params) walkExpr(mp, cb); diff --git a/src/checkstyle/utils/FieldUtils.hx b/src/checkstyle/utils/FieldUtils.hx index be56d5fa..bf255c8b 100644 --- a/src/checkstyle/utils/FieldUtils.hx +++ b/src/checkstyle/utils/FieldUtils.hx @@ -1,7 +1,6 @@ package checkstyle.utils; class FieldUtils { - public static function isPublic(f:Field, p:ParentType):Bool { if (f.access.contains(APublic)) return true; if (f.access.contains(APrivate)) return false; @@ -49,13 +48,13 @@ class FieldUtils { switch (decl) { case EClass(d): var kind = d.flags.contains(HInterface) ? INTERFACE : CLASS; - return {decl:decl, kind:kind}; + return {decl: decl, kind: kind}; case EAbstract(a): var metaName = #if (haxeparser > "3.2.0") ":enum" #else ":kwdenum" #end; var kind = a.meta.hasMeta(metaName) ? ENUM_ABSTRACT : ABSTRACT; - return {decl:decl, kind:kind}; + return {decl: decl, kind: kind}; case ETypedef(d): - return return {decl:decl, kind:TYPEDEF}; + return return {decl: decl, kind: TYPEDEF}; default: return null; } diff --git a/src/checkstyle/utils/StringUtils.hx b/src/checkstyle/utils/StringUtils.hx index f166a7ac..619bdab9 100644 --- a/src/checkstyle/utils/StringUtils.hx +++ b/src/checkstyle/utils/StringUtils.hx @@ -1,7 +1,6 @@ package checkstyle.utils; class StringUtils { - public static inline function contains(s:String, c:String):Bool { return s.indexOf(c) != -1; } diff --git a/src/checkstyle/utils/Thread.hx b/src/checkstyle/utils/Thread.hx index 50343eb7..e4352019 100644 --- a/src/checkstyle/utils/Thread.hx +++ b/src/checkstyle/utils/Thread.hx @@ -2,7 +2,7 @@ package checkstyle.utils; #if (!neko && !cpp && !hl) class Thread { - public static function create( f : Void -> Void ) { + public static function create(f:Void -> Void) { f(); } } diff --git a/test/TestMain.hx b/test/TestMain.hx index 0fbcee81..43f4ebdd 100644 --- a/test/TestMain.hx +++ b/test/TestMain.hx @@ -1,11 +1,8 @@ import haxe.EntryPoint; import haxe.Json; - import sys.io.File; import sys.io.FileOutput; - import massive.munit.TestRunner; - import mcover.coverage.munit.client.MCoverPrintClient; import mcover.coverage.data.CoverageResult; import mcover.coverage.data.Statement; @@ -15,7 +12,6 @@ import mcover.coverage.MCoverage; using StringTools; class TestMain { - public function new() { var suites:Array> = [TestSuite]; @@ -42,7 +38,7 @@ class TestMain { } function setupCoverageReport() { - var report = { coverage: {} }; + var report = {coverage: {}}; var classes = MCoverage.getLogger().coverage.getClasses(); for (cls in classes) { var coverageData:Array = [null]; diff --git a/test/TestSuite.hx b/test/TestSuite.hx index daaedae6..f3accb07 100644 --- a/test/TestSuite.hx +++ b/test/TestSuite.hx @@ -8,7 +8,6 @@ import misc.ThreadTest; #end class TestSuite extends massive.munit.TestSuite { - public function new() { super(); diff --git a/test/checks/CheckTestCase.hx b/test/checks/CheckTestCase.hx index 54361a5d..96305169 100644 --- a/test/checks/CheckTestCase.hx +++ b/test/checks/CheckTestCase.hx @@ -1,7 +1,6 @@ package checks; import byte.ByteData; - import checkstyle.CheckMessage; import checkstyle.CheckFile; import checkstyle.reporter.IReporter; @@ -10,7 +9,6 @@ import checkstyle.Checker; import checkstyle.checks.Check; class CheckTestCase { - static inline var FILE_NAME:String = "Test.hx"; var checker:Checker; @@ -48,7 +46,7 @@ class CheckTestCase { ReporterManager.INSTANCE.clear(); ReporterManager.INSTANCE.addReporter(reporter); - checker.process([{name:fileName, content:ByteData.ofString(src), index:0}]); + checker.process([{name: fileName, content: ByteData.ofString(src), index: 0}]); return reporter.message; } @@ -60,7 +58,6 @@ class CheckTestCase { } class TestReporter implements IReporter { - public var message:String; public function new() { diff --git a/test/checks/block/BlockTest.hx b/test/checks/block/BlockTest.hx index db97460c..56fe9048 100644 --- a/test/checks/block/BlockTest.hx +++ b/test/checks/block/BlockTest.hx @@ -6,7 +6,6 @@ import checkstyle.checks.block.RightCurlyCheck; // tests for blocks using multiple check classes class BlockTest extends CheckTestCase { - @Test public function testBlockFormatIssue42() { var check:EmptyBlockCheck = new EmptyBlockCheck(); @@ -52,7 +51,6 @@ abstract BlockTests(String) to String { } } }"; - var ISSUE_42_MACRO = " abstractAndClass Macro { @@ -65,7 +63,6 @@ abstract BlockTests(String) to String { } } }"; - var ISSUE_42_MACRO_EOL = " abstractAndClass Macro { function build() { @@ -75,7 +72,6 @@ abstract BlockTests(String) to String { } } }"; - var CONDITIONAL_TEST = " abstractAndClass Test { #if false diff --git a/test/checks/block/ConditionalCompilationTest.hx b/test/checks/block/ConditionalCompilationTest.hx index 82a6f7d1..f9f3d11a 100644 --- a/test/checks/block/ConditionalCompilationTest.hx +++ b/test/checks/block/ConditionalCompilationTest.hx @@ -3,7 +3,6 @@ package checks.block; import checkstyle.checks.block.ConditionalCompilationCheck; class ConditionalCompilationTest extends CheckTestCase { - static inline var MSG_START_OF_LINE:String = "#if should start at beginning of line"; static inline var MSG_NOT_ALIGNED:String = "Indentation of #if should match surrounding lines"; static inline var MSG_NO_SINGLELINE:String = "Single line #if…(#else/#elseif)…#end not allowed"; @@ -79,7 +78,6 @@ abstract ConditionalCompilationTests(String) to String { #end { }"; - var ISSUE_79 = " class Test { function foo() { @@ -93,7 +91,6 @@ abstract ConditionalCompilationTests(String) to String { } } }"; - var ISSUE_79_WRONG_INDENT = " class Test { function foo() { @@ -106,7 +103,6 @@ abstract ConditionalCompilationTests(String) to String { } } }"; - var ISSUE_79_WHITESPACE_BEFORE = " class Test { function foo() { #if true @@ -117,7 +113,6 @@ abstract ConditionalCompilationTests(String) to String { } } }"; - var ISSUE_79_WHITESPACE_AFTER = " class Test { function foo() { @@ -128,7 +123,6 @@ abstract ConditionalCompilationTests(String) to String { } } }"; - var ISSUE_76_START_OF_LINE = " class Base {} @@ -140,7 +134,6 @@ abstract ConditionalCompilationTests(String) to String { #end { }"; - var ISSUE_79_START_OF_LINE = " class Test { function foo() { @@ -153,7 +146,6 @@ abstract ConditionalCompilationTests(String) to String { } } }"; - var ISSUE_252 = " class Foo { var library = new #if haxe3 Map(); diff --git a/test/checks/block/EmptyBlockCheckTest.hx b/test/checks/block/EmptyBlockCheckTest.hx index 112f6a9d..1cd4464a 100644 --- a/test/checks/block/EmptyBlockCheckTest.hx +++ b/test/checks/block/EmptyBlockCheckTest.hx @@ -3,7 +3,6 @@ package checks.block; import checkstyle.checks.block.EmptyBlockCheck; class EmptyBlockCheckTest extends CheckTestCase { - static inline var MSG_EMPTY_BLOCK:String = 'Empty block should be written as "{}"'; static inline var MSG_EMPTY_BLOCK_SHOULD_CONTAIN:String = "Empty block should contain a comment or a statement"; static inline var MSG_EMPTY_BLOCK_CONTAIN_STATEMENT:String = "Empty block should contain a statement"; @@ -94,41 +93,35 @@ abstract EmptyBlockCheckTests(String) to String { public function test() { } }"; - var EMPTY_BLOCK_WHITESPACE = " class Test { public function new(){ } }"; - var BLOCK_WITH_STATEMENT = " class Test { public function new() { var a:Int; } }"; - var BLOCK_WITH_STATEMENT2 = " class Test { public function new() { var a:Int; } }"; - var BLOCK_WITH_COMMENT = " class Test { public function new() { // comment } }"; - var EMPTY_OBJECT_DECL = " class Test { public function new() { var a = {}; } }"; - var EMPTY_OBJECT_DECL_WHITESPACE = " class Test { public function new() { @@ -136,7 +129,6 @@ abstract EmptyBlockCheckTests(String) to String { }; } }"; - var OBJECT_DECL_WITH_COMMENT = " class Test { public function new() { @@ -145,7 +137,6 @@ abstract EmptyBlockCheckTests(String) to String { }; } }"; - var OBJECT_DECL_WITH_COMMENT2 = " class Test { public function new() { /* comment @@ -154,7 +145,6 @@ abstract EmptyBlockCheckTests(String) to String { }; } }"; - var NESTED_OBJECT_DECL = " class Test { public function new() { @@ -167,7 +157,6 @@ abstract EmptyBlockCheckTests(String) to String { }; } }"; - var MACRO_REIFICATION_ISSUE_149 = " class Macro { diff --git a/test/checks/block/LeftCurlyCheckTest.hx b/test/checks/block/LeftCurlyCheckTest.hx index b9887e27..7aa906c8 100644 --- a/test/checks/block/LeftCurlyCheckTest.hx +++ b/test/checks/block/LeftCurlyCheckTest.hx @@ -3,7 +3,6 @@ package checks.block; import checkstyle.checks.block.LeftCurlyCheck; class LeftCurlyCheckTest extends CheckTestCase { - static inline var MSG_EOL:String = "Left curly should be at EOL (only line break or comment after curly)"; static inline var MSG_NL:String = "Left curly should be on new line (only whitespace before curly)"; static inline var MSG_NL_SPLIT:String = "Left curly should be on new line (previous expression is split over multiple lines)"; @@ -173,7 +172,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST1 = " class Test { function test() { @@ -183,7 +181,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST2 = " class Test { function test() { @@ -195,7 +192,6 @@ abstract LeftCurlyCheckTests(String) to String { return; } }"; - var TEST3 = " class Test { function test() @@ -208,7 +204,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST4 = " class Test { function test() { @@ -217,7 +212,6 @@ abstract LeftCurlyCheckTests(String) to String { z:3 }; } }"; - var TEST5 = " class Test { function test() { @@ -227,7 +221,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST6 = " class Test { function test() { @@ -236,14 +229,12 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST7 = " class Test { function test() { while (true) { return i; } } }"; - var TEST8 = " class Test { function test() { @@ -252,14 +243,12 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST9 = " class Test { function test() { for (i in 0....10) return i; } }"; - var TEST10 = " class Test { @@ -267,14 +256,12 @@ abstract LeftCurlyCheckTests(String) to String { if (true) return; } }"; - var TEST12 = " class Test { function test() { var struct = {x:10, y:10, z:20}; } }"; - var TEST13 = " class Test { @@ -293,7 +280,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST14 = " typedef Test = { x:Int, @@ -301,7 +287,6 @@ abstract LeftCurlyCheckTests(String) to String { z:Int, point:{x:Int, y:Int, z:Int} }"; - var TEST15 = " class Test { @@ -315,7 +300,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST16 = " class Test { public function test(val:Int, @@ -329,7 +313,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST17 = " class Test { public function test(val:Int, val2:Int):String @@ -341,7 +324,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST18 = " class Test { public function test(val:Int, @@ -354,7 +336,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var TEST19 = " class Test { public function test(val:Int, @@ -367,7 +348,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var NL_CASEBLOCK = " class Test { @@ -384,7 +364,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var EOL_CASEBLOCK = " class Test { public function test(val:Int, @@ -397,7 +376,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var NLOW_CASEBLOCK = " class Test { public function test(val:Int, @@ -413,7 +391,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var MACRO_REIFICATION = " class Test { public function test(val:Int) { @@ -422,16 +399,13 @@ abstract LeftCurlyCheckTests(String) to String { var e = macro ${str}.toLowerCase(); } }"; - var NO_FIELDS_CLASS = " class Test {} "; - var NO_FIELDS_MACRO = " class Test { var definition = macro class Font extends flash.text.Font {}; }"; - var ISSUE_97 = " class Test { function foo() { @@ -458,7 +432,6 @@ abstract LeftCurlyCheckTests(String) to String { } } }"; - var ARRAY_COMPREHENSION_ISSUE_114 = " class Test { public function foo() { @@ -466,7 +439,6 @@ abstract LeftCurlyCheckTests(String) to String { [for (x in 0...10) for (y in 0...10) {x:x, y:y}]; } }"; - var ARRAY_COMPREHENSION_2_ISSUE_114 = " class Test { public function foo() { @@ -480,7 +452,6 @@ abstract LeftCurlyCheckTests(String) to String { }]; } }"; - var ARRAY_COMPREHENSION_NLOW_ISSUE_114 = " class Test { public function foo() { @@ -493,7 +464,6 @@ abstract LeftCurlyCheckTests(String) to String { }]; } }"; - var SINGLELINE_ISSUE_153 = " class Test { var positionMap = new Map(); @@ -501,7 +471,6 @@ abstract LeftCurlyCheckTests(String) to String { } class Empty {}"; - var ABSTRACT = " abstract MyAbstract(Int) from Int to Int { inline function new(i:Int) { diff --git a/test/checks/block/NeedBracesCheckTest.hx b/test/checks/block/NeedBracesCheckTest.hx index e43113ec..fa330fad 100644 --- a/test/checks/block/NeedBracesCheckTest.hx +++ b/test/checks/block/NeedBracesCheckTest.hx @@ -3,18 +3,15 @@ package checks.block; import checkstyle.checks.block.NeedBracesCheck; class NeedBracesCheckTest extends CheckTestCase { - static inline var PREFIX:String = "No braces used for body of "; static inline var MSG_IF:String = PREFIX + '"if"'; static inline var MSG_ELSE:String = PREFIX + '"else"'; static inline var MSG_FOR:String = PREFIX + '"for"'; static inline var MSG_WHILE:String = PREFIX + '"while"'; - static inline var MSG_SAME_LINE_IF:String = 'Body of "if" on same line'; static inline var MSG_SAME_LINE_ELSE:String = 'Body of "else" on same line'; static inline var MSG_SAME_LINE_FOR:String = 'Body of "for" on same line'; static inline var MSG_SAME_LINE_WHILE:String = 'Body of "while" on same line'; - static inline var MSG_SAME_LINE_FUNCTION:String = 'Body of "function" on same line'; static inline var MSG_SAME_LINE_DO_WHILE:String = 'Body of "do" on same line'; @@ -278,7 +275,6 @@ abstract NeedBracesCheckTests(String) to String { return; } }"; - var TEST1 = " class Test { function test() { @@ -286,7 +282,6 @@ abstract NeedBracesCheckTests(String) to String { return; } }"; - var TEST2 = " class Test { function test() { @@ -295,7 +290,6 @@ abstract NeedBracesCheckTests(String) to String { return; } }"; - var TEST3 = " class Test { function test() { @@ -307,7 +301,6 @@ abstract NeedBracesCheckTests(String) to String { } } }"; - var TEST4 = " class Test { function test() { @@ -316,7 +309,6 @@ abstract NeedBracesCheckTests(String) to String { z:3 }; } }"; - var TEST5 = " class Test { function test() { @@ -325,7 +317,6 @@ abstract NeedBracesCheckTests(String) to String { } } }"; - var TEST6 = " class Test { function test() { @@ -334,7 +325,6 @@ abstract NeedBracesCheckTests(String) to String { } } }"; - var TEST7 = " class Test { function test() { @@ -342,7 +332,6 @@ abstract NeedBracesCheckTests(String) to String { return i; } }"; - var TEST8 = " class Test { function test() { @@ -351,21 +340,18 @@ abstract NeedBracesCheckTests(String) to String { } } }"; - var TEST9 = " class Test { function test() { for (i in 0....10) return i; } }"; - var TEST10 = " class Test { function test() { if (true) return; } }"; - var TEST11 = " class Test { function test() { @@ -374,7 +360,6 @@ abstract NeedBracesCheckTests(String) to String { else return; } }"; - var TEST12 = " class Test { function test() { @@ -384,7 +369,6 @@ abstract NeedBracesCheckTests(String) to String { } } }"; - var TEST13 = " class Test { function test() { @@ -392,7 +376,6 @@ abstract NeedBracesCheckTests(String) to String { else if (false) { return; } } }"; - var TEST14 = " class Test { function test() { @@ -403,7 +386,6 @@ abstract NeedBracesCheckTests(String) to String { } } }"; - var TEST15 = " class Test { public function test(a:Bool, b:Bool) { @@ -415,7 +397,6 @@ abstract NeedBracesCheckTests(String) to String { } } }"; - var TEST16 = " class Test { function test() { @@ -425,12 +406,10 @@ abstract NeedBracesCheckTests(String) to String { else return; } }"; - var INTERFACE_DEF = " interface Test { function test(); }"; - var ANON_FUNCTION = " abstractAndClass Test { function test() { @@ -439,14 +418,12 @@ abstract NeedBracesCheckTests(String) to String { }, false); } }"; - var ANON_FUNCTION_NO_BRACES = " abstractAndClass Test { function test() { doSomething(function() doIt(), false); } }"; - var DO_WHILE = " class Test { function test() { @@ -456,7 +433,6 @@ abstract NeedBracesCheckTests(String) to String { while (true); } }"; - var DO_WHILE_NO_BRACES = " class Test { function test() { diff --git a/test/checks/block/RightCurlyCheckTest.hx b/test/checks/block/RightCurlyCheckTest.hx index d3d21ddd..41f7c77f 100644 --- a/test/checks/block/RightCurlyCheckTest.hx +++ b/test/checks/block/RightCurlyCheckTest.hx @@ -3,7 +3,6 @@ package checks.block; import checkstyle.checks.block.RightCurlyCheck; class RightCurlyCheckTest extends CheckTestCase { - static inline var MSG_ALONE:String = "Right curly should be alone on a new line"; static inline var MSG_NOT_SAME_LINE:String = "Right curly should not be on same line as left curly"; static inline var MSG_SAME_LINE:String = 'Right curly should be on same line as following block (e.g. "} else" or "} catch")'; @@ -260,14 +259,12 @@ abstract RightCurlyCheckTests(String) to String { { return; } } }"; - var SINGLELINE_IF = " class Test { function test() { if (true) { return; } else { return; } } }"; - var SAMELINE_IF = " class Test { function test() { @@ -278,7 +275,6 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var ALONE_IF = " class Test { function test() { @@ -290,26 +286,22 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var SINGLELINE_FUNCTION = " class Test { function test() { trace ('test'); } }"; - var ALONE_FUNCTION = " class Test { function test() { trace ('test'); } }"; - var SINGLELINE_FOR = " class Test { function test() { for (i in 0...100) { trace ('$i'); } } }"; - var ALONE_FOR = " class Test { function test() { @@ -318,14 +310,12 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var SINGLELINE_WHILE = " class Test { function test() { while (true) { trace ('test'); } } }"; - var ALONE_WHILE = " class Test { function test() { @@ -334,14 +324,12 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var SINGLELINE_TRY_CATCH = " class Test { function test() { try { trace ('test'); } catch (e:Dynamic) {} } }"; - var SAMELINE_TRY_CATCH = " class Test { function test() { @@ -351,7 +339,6 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var ALONE_TRY_CATCH = " class Test { function test() { @@ -362,41 +349,33 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var SINGLELINE_INTERFACE = " interface Test { function test(); }"; - var ALONE_INTERFACE = " interface Test { function test(); }"; - var SINGLELINE_CLASS = " class Test { function test() {}; }"; - var ALONE_CLASS = " class Test { function test() { }; }"; - var SINGLELINE_TYPEDEF = " typedef Test = { x:Int, y:Int, z:Int }"; - var ALONE_TYPEDEF = " typedef Test = { x:Int, y:Int, z:Int }"; - var SINGLELINE_SWITCH = " class Test { function test(val:Bool) { switch (val) { case true: return; default: trace(val); } } }"; - var ALONE_SWITCH = " class Test { function test() { @@ -408,7 +387,6 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var SINGLELINE_CASE = " class Test { function test(val:Bool) { @@ -419,7 +397,6 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var ALONE_CASE = " class Test { function test() { @@ -436,14 +413,12 @@ abstract RightCurlyCheckTests(String) to String { } } }"; - var SINGLELINE_OBJECT = " class Test { function test(val:Bool) { var p = { x:100, y: 10, z: 2 }; } }"; - var ALONE_OBJECT = " class Test { function test() { @@ -454,10 +429,8 @@ abstract RightCurlyCheckTests(String) to String { }; } }"; - var SINGLELINE_ABSTRACT = " abstract Test(String) { @:from public static function fromString(value:String) { return new Test('Hello $value'); } }"; - var ALONE_ABSTRACT = " abstract Test(String) { @:from @@ -465,10 +438,8 @@ abstract RightCurlyCheckTests(String) to String { return new Test('Hello $value'); } }"; - var SINGLELINE_ENUM = " enum Test { Monday; Tuesday; Wednesday; Thursday; Friday; Weekend(day:String); }"; - var ALONE_ENUM = " enum Test { Monday; @@ -478,7 +449,6 @@ abstract RightCurlyCheckTests(String) to String { Friday; Weekend(day:String); }"; - var SINGLELINE_NESTED_OBJECT = " class Test { public function test() { @@ -491,7 +461,6 @@ abstract RightCurlyCheckTests(String) to String { { x:200, y: 50, z: 2 }]; } }"; - var SAMELINE_NESTED_OBJECT = " class Test { public function test() { @@ -519,7 +488,6 @@ abstract RightCurlyCheckTests(String) to String { }]; } }"; - var ALONE_NESTED_OBJECT = " class Test { public function test() { @@ -549,7 +517,6 @@ abstract RightCurlyCheckTests(String) to String { ]; } }"; - var MACRO_REIFICATION = " class Test { public function test(val:Int) { @@ -558,7 +525,6 @@ abstract RightCurlyCheckTests(String) to String { var e = macro ${str}.toLowerCase(); } }"; - var ARRAY_COMPREHENSION_ISSUE_114 = " class Test { public function foo() { @@ -566,7 +532,6 @@ abstract RightCurlyCheckTests(String) to String { [for (x in 0...10) for (y in 0...10) {x:x, y:y}]; } }"; - var ARRAY_COMPREHENSION_2_ISSUE_114 = " class Test { public function foo() { @@ -580,7 +545,6 @@ abstract RightCurlyCheckTests(String) to String { }]; } }"; - var CONSTRUCTOR_OBJECT_DECL_ISSUE_152 = " class Test { var field = new Object({x:0}); diff --git a/test/checks/coding/AvoidInlineConditionalsCheckTest.hx b/test/checks/coding/AvoidInlineConditionalsCheckTest.hx index 21505758..fefd23db 100644 --- a/test/checks/coding/AvoidInlineConditionalsCheckTest.hx +++ b/test/checks/coding/AvoidInlineConditionalsCheckTest.hx @@ -4,7 +4,6 @@ import checkstyle.SeverityLevel; import checkstyle.checks.coding.AvoidInlineConditionalsCheck; class AvoidInlineConditionalsCheckTest extends CheckTestCase { - @Test public function testInlineCondition() { var check = new AvoidInlineConditionalsCheck(); diff --git a/test/checks/coding/DefaultComesLastCheckTest.hx b/test/checks/coding/DefaultComesLastCheckTest.hx index 5f06f3a2..9e4a412e 100644 --- a/test/checks/coding/DefaultComesLastCheckTest.hx +++ b/test/checks/coding/DefaultComesLastCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.DefaultComesLastCheck; class DefaultComesLastCheckTest extends CheckTestCase { - static inline var MSG:String = 'Default should be last label in the "switch"'; @Test @@ -36,7 +35,6 @@ abstract DefaultComesLastCheckTests(String) to String { } } }"; - var TEST2 = " abstractAndClass Test { @@ -49,7 +47,6 @@ abstract DefaultComesLastCheckTests(String) to String { } } }"; - var TEST3 = " abstractAndClass Test { diff --git a/test/checks/coding/HiddenFieldCheckTest.hx b/test/checks/coding/HiddenFieldCheckTest.hx index c5dcd3a3..54e6c11e 100644 --- a/test/checks/coding/HiddenFieldCheckTest.hx +++ b/test/checks/coding/HiddenFieldCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.HiddenFieldCheck; class HiddenFieldCheckTest extends CheckTestCase { - @Test public function testCorrectHidden() { var check = new HiddenFieldCheck(); @@ -89,7 +88,6 @@ abstract HiddenFieldCheckTests(String) to String { var field2:String = ''; } }"; - var HIDDEN_FIELDS_CONSTRUCTOR = " class Test { var field1:Int; @@ -98,7 +96,6 @@ abstract HiddenFieldCheckTests(String) to String { this.field1 = field1; } }"; - var HIDDEN_FIELDS_CONSTRUCTOR_VAR = " class Test { var field1:Int; @@ -108,7 +105,6 @@ abstract HiddenFieldCheckTests(String) to String { var field2:String = 'test'; } }"; - var HIDDEN_FIELDS_SETTER = " class Test { var field1:Int; @@ -120,7 +116,6 @@ abstract HiddenFieldCheckTests(String) to String { field2 = field2; } }"; - var HIDDEN_FIELDS_FUNC = " class Test { var field1:Int; @@ -129,7 +124,6 @@ abstract HiddenFieldCheckTests(String) to String { field2 = field1; } }"; - var HIDDEN_FIELDS_MAIN = " class Test { var field1:Int; @@ -138,7 +132,6 @@ abstract HiddenFieldCheckTests(String) to String { var field2:String = 'test'; } }"; - var HIDDEN_FIELDS_FOR = " class Test { var field1:Int; @@ -147,7 +140,6 @@ abstract HiddenFieldCheckTests(String) to String { for (field1 in []) trace(field1); } }"; - var HIDDEN_FIELDS_FUNC_WITH_COMMENT = " class Test { var field1:Int; @@ -156,7 +148,6 @@ abstract HiddenFieldCheckTests(String) to String { field2 = field1; } }"; - var HIDDEN_FIELDS_CONSTRUCTOR_VAR_WITH_COMMENT = " class Test { var field1:Int; diff --git a/test/checks/coding/InnerAssignmentCheckTest.hx b/test/checks/coding/InnerAssignmentCheckTest.hx index cb9385dc..e942ba18 100644 --- a/test/checks/coding/InnerAssignmentCheckTest.hx +++ b/test/checks/coding/InnerAssignmentCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.InnerAssignmentCheck; class InnerAssignmentCheckTest extends CheckTestCase { - static inline var MSG_INNER_ASSIGNMENT:String = "Inner assignment detected"; @Test @@ -27,7 +26,7 @@ class InnerAssignmentCheckTest extends CheckTestCase } @Test - public function testIgnoreReturnAssignments () { + public function testIgnoreReturnAssignments() { var check = new InnerAssignmentCheck(); check.ignoreReturnAssignments = true; assertNoMsg(check, IF_EXPR); @@ -57,21 +56,18 @@ abstract InnerAssignmentCheckTests(String) to String { if ((a=b) > 0) return; } }"; - var IF_EXPR = " abstractAndClass Test { public function new() { if (a==b) a=b; } }"; - var IF_RETURN_EXPR = " abstractAndClass Test { public function new() { if (a==b) return a=b; } }"; - var WHILE_COND = " abstractAndClass Test { public function new() { @@ -81,7 +77,6 @@ abstract InnerAssignmentCheckTests(String) to String { while ((a=b) > 0) b = c; } }"; - var WHILE_COND_RETURN = " abstractAndClass Test { public function new() { @@ -90,13 +85,11 @@ abstract InnerAssignmentCheckTests(String) to String { } } }"; - var METHOD_DEF = " abstractAndClass Test { public function new(a:Null = 1, b:String = 'test', c = []) { } }"; - var MEMBER_DEF = " abstractAndClass Test { var a:Null = 1; @@ -106,7 +99,6 @@ abstract InnerAssignmentCheckTests(String) to String { public function new() { } }"; - var SWITCH = " class Test { public function new() { @@ -117,7 +109,6 @@ abstract InnerAssignmentCheckTests(String) to String { } } }"; - var BRACELESS_ANON_FUNC_ISSUE_113 = " class Test { public function foo() { @@ -125,8 +116,7 @@ abstract InnerAssignmentCheckTests(String) to String { trace(function() b = true); } }"; - - var SETTER_GETTER_ISSUE_259 = " + var SETTER_GETTER_ISSUE_259 = " class Test { @:isVar public var value(get, set) : String; @@ -134,28 +124,23 @@ abstract InnerAssignmentCheckTests(String) to String { private function set_value(value : String) : String { return this.value = value; } private function set_value(value : String) : String return this.value = value; }"; - - var INCORRECT_SETTER_GETTER_MULTIPLE_STATEMENTS_ISSUE_259 = " + var INCORRECT_SETTER_GETTER_MULTIPLE_STATEMENTS_ISSUE_259 = " class Test { private function set_value(value : String) : String { StringTools.trim(value); return this.value = value; } }"; - - var INCORRECT_SETTER_GETTER_MULTIPLE_BINOP_ISSUE_259 = " + var INCORRECT_SETTER_GETTER_MULTIPLE_BINOP_ISSUE_259 = " class Test { private function set_value(value : String) : String { return this.value = value + 1; } }"; - - var INCORRECT_SETTER_GETTER_UNOP_ISSUE_259 = " + var INCORRECT_SETTER_GETTER_UNOP_ISSUE_259 = " class Test { private function set_value(value : Int) : Int { return this.value = ++value; } }"; - - var INCORRECT_SETTER_GETTER_ARRAY_ACCESS_ISSUE_259 = " + var INCORRECT_SETTER_GETTER_ARRAY_ACCESS_ISSUE_259 = " class Test { private function set_value(value : Array) : String { return this.value = value[0]; } }"; - - var INCORRECT_SETTER_GETTER_CALL_ISSUE_259 = " + var INCORRECT_SETTER_GETTER_CALL_ISSUE_259 = " class Test { private function set_value(value : String) : String { return this.value = StringTools.trim(value); } }"; diff --git a/test/checks/coding/MagicNumberCheckTest.hx b/test/checks/coding/MagicNumberCheckTest.hx index ebe6df5f..f7757f16 100644 --- a/test/checks/coding/MagicNumberCheckTest.hx +++ b/test/checks/coding/MagicNumberCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.MagicNumberCheck; class MagicNumberCheckTest extends CheckTestCase { - @Test public function testNoMagicNumber() { var check = new MagicNumberCheck(); @@ -59,41 +58,35 @@ abstract MagicNumberCheckTests(String) to String { d = 2; } }"; - var INT_NUMBER_ASSIGN = " abstractAndClass Test { public function new() { a = 5; } }"; - var NEGATIVE_INT_NUMBER_ASSIGN = " abstractAndClass Test { public function new() { a = -2; } }"; - var FLOAT_NUMBER_ASSIGN = " abstractAndClass Test { public function new() { a = 5.0; } }"; - var INT_NUMBER_IF = " abstractAndClass Test { public function new() { if (a > 5) return; } }"; - var INT_NUMBER_FUNCTION = " abstractAndClass Test { public function new(a:Int = 10) { } }"; - var ALLOWED_MAGIC_NUMBER = " abstractAndClass Test { static inline var VAL = 5; @@ -101,7 +94,6 @@ abstract MagicNumberCheckTests(String) to String { a = VAL; } }"; - var ENUM_ABSTRACT = " @:enum abstract Style(Int) { var BOLD = 1; @@ -109,7 +101,6 @@ abstract MagicNumberCheckTests(String) to String { var BLUE = 94; var MAGENTA = 95; }"; - var ENUM_ABSTRACT_WITH_CLASS = " @:enum abstract Style(Int) { var BOLD = 1; @@ -122,7 +113,6 @@ abstract MagicNumberCheckTests(String) to String { static inline var VAL = 5; } "; - var HAXE4_ENUM_ABSTRACT = " enum abstract Style(Int) { var BOLD = 1; diff --git a/test/checks/coding/MultipleVariableDeclarationsCheckTest.hx b/test/checks/coding/MultipleVariableDeclarationsCheckTest.hx index 7f355027..11ed422d 100644 --- a/test/checks/coding/MultipleVariableDeclarationsCheckTest.hx +++ b/test/checks/coding/MultipleVariableDeclarationsCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.MultipleVariableDeclarationsCheck; class MultipleVariableDeclarationsCheckTest extends CheckTestCase { - static inline var MSG_MULTI_VAR_COMMA:String = "Each variable declaration must be in its own statement"; static inline var MSG_MULTI_VAR:String = "Only one variable definition per line allowed"; @@ -33,14 +32,12 @@ abstract MultipleVariableDeclarationsCheckTests(String) to String { var d,e = 2; } }"; - var TEST2 = " abstractAndClass Test { function a() { var d,e,f; } }"; - var TEST3 = " abstractAndClass Test { function a() { @@ -49,7 +46,6 @@ abstract MultipleVariableDeclarationsCheckTests(String) to String { var f; var g; } }"; - var TEST4 = " abstractAndClass Test { function a() { @@ -57,7 +53,6 @@ abstract MultipleVariableDeclarationsCheckTests(String) to String { var e = 2; } }"; - var TEST5 = " abstractAndClass Test { function foo() { diff --git a/test/checks/coding/NestedForDepthCheckTest.hx b/test/checks/coding/NestedForDepthCheckTest.hx index 82b2d682..441caf07 100644 --- a/test/checks/coding/NestedForDepthCheckTest.hx +++ b/test/checks/coding/NestedForDepthCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.NestedForDepthCheck; class NestedForDepthCheckTest extends CheckTestCase { - @Test public function testDefault() { var check = new NestedForDepthCheck(); @@ -69,7 +68,6 @@ abstract NestedForDepthCheckTests(String) to String { } } }"; - var TEST2 = " abstractAndClass Test { public function test1(param:Array) { diff --git a/test/checks/coding/NestedIfDepthCheckTest.hx b/test/checks/coding/NestedIfDepthCheckTest.hx index 8fc581d2..82269e76 100644 --- a/test/checks/coding/NestedIfDepthCheckTest.hx +++ b/test/checks/coding/NestedIfDepthCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.NestedIfDepthCheck; class NestedIfDepthCheckTest extends CheckTestCase { - @Test public function testDefault() { var check = new NestedIfDepthCheck(); @@ -58,7 +57,6 @@ abstract NestedIfDepthCheckTests(String) to String { return 3; } }"; - var TEST2 = " abstractAndClass Test { public function test1(param:Int) { diff --git a/test/checks/coding/NestedTryDepthCheckTest.hx b/test/checks/coding/NestedTryDepthCheckTest.hx index 6c804656..f485b3f7 100644 --- a/test/checks/coding/NestedTryDepthCheckTest.hx +++ b/test/checks/coding/NestedTryDepthCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.NestedTryDepthCheck; class NestedTryDepthCheckTest extends CheckTestCase { - @Test public function testDefault() { var check = new NestedTryDepthCheck(); @@ -64,7 +63,6 @@ abstract NestedTryDepthCheckTests(String) to String { } } }"; - var TEST2 = " abstractAndClass Test { public function test1() { diff --git a/test/checks/coding/NullableParameterCheckTest.hx b/test/checks/coding/NullableParameterCheckTest.hx index 12cb1bbe..7642abac 100644 --- a/test/checks/coding/NullableParameterCheckTest.hx +++ b/test/checks/coding/NullableParameterCheckTest.hx @@ -4,7 +4,6 @@ import checks.CheckTestCase; import checkstyle.checks.coding.NullableParameterCheck; class NullableParameterCheckTest extends CheckTestCase { - @Test function testQuestionMark() { var check = new NullableParameterCheck(); @@ -38,27 +37,22 @@ abstract NullableParameterCheckTests(String) to String { class Test { function foo(arg:Int) {} }"; - var DEFAULT = " class Test { function foo(arg:Int = 0) {} }"; - var NULL_DEFAULT = " class Test { function foo(arg:Int = null) {} }"; - var OPTIONAL = " class Test { function foo(?arg:Int) {} }"; - var OPTIONAL_WITH_NULL_DEFAULT = " class Test { function foo(?arg:Int = null) {} }"; - var OPTIONAL_WITH_NON_NULL_DEFAULT = " class Test { function foo(?arg:Int = 0) {} diff --git a/test/checks/coding/ReturnCountCheckTest.hx b/test/checks/coding/ReturnCountCheckTest.hx index cb366432..7722ca27 100644 --- a/test/checks/coding/ReturnCountCheckTest.hx +++ b/test/checks/coding/ReturnCountCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.ReturnCountCheck; class ReturnCountCheckTest extends CheckTestCase { - @Test public function testReturnCount() { assertMsg(new ReturnCountCheck(), TEST1, "Return count is 3 (max allowed is 2)"); @@ -50,7 +49,6 @@ abstract ReturnCountCheckTests(String) to String { return 3; } }"; - var TEST2 = " abstractAndClass Test { function a() { @@ -60,7 +58,6 @@ abstract ReturnCountCheckTests(String) to String { } } }"; - var TEST3 = " abstractAndClass Test { @SuppressWarnings('checkstyle:ReturnCount') @@ -72,7 +69,6 @@ abstract ReturnCountCheckTests(String) to String { else return 3; } }"; - var TEST4 = " abstractAndClass Test { function a() { @@ -82,7 +78,6 @@ abstract ReturnCountCheckTests(String) to String { } } }"; - var TEST5 = " abstractAndClass Test { function equals() { @@ -91,7 +86,6 @@ abstract ReturnCountCheckTests(String) to String { return 3; } }"; - var RETURN_IN_CLOSURE = " abstractAndClass Test { function equals() { @@ -100,7 +94,6 @@ abstract ReturnCountCheckTests(String) to String { return a() + b(); } }"; - var RETURN_IN_CLOSURE_2 = " abstractAndClass Test { function equals() { diff --git a/test/checks/coding/SimplifyBooleanExpressionCheckTest.hx b/test/checks/coding/SimplifyBooleanExpressionCheckTest.hx index 074e8862..87ed3732 100644 --- a/test/checks/coding/SimplifyBooleanExpressionCheckTest.hx +++ b/test/checks/coding/SimplifyBooleanExpressionCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.SimplifyBooleanExpressionCheck; class SimplifyBooleanExpressionCheckTest extends CheckTestCase { - static inline var MSG_SIMPLIFY:String = "Boolean expression can be simplified"; @Test @@ -35,7 +34,6 @@ abstract SimplifyBooleanExpressionCheckTests(String) to String { if (bvar == true) {} } }"; - var TEST2 = " abstractAndClass Test { function test() { @@ -43,7 +41,6 @@ abstract SimplifyBooleanExpressionCheckTests(String) to String { if (bvar || true) {} } }"; - var TEST3 = " abstractAndClass Test { function test() { @@ -51,7 +48,6 @@ abstract SimplifyBooleanExpressionCheckTests(String) to String { if (bvar != true) {} } }"; - var TEST4 = " abstractAndClass Test { function test() { @@ -59,7 +55,6 @@ abstract SimplifyBooleanExpressionCheckTests(String) to String { if (!false) {} } }"; - var TEST5 = " abstractAndClass Test { function test() { @@ -67,7 +62,6 @@ abstract SimplifyBooleanExpressionCheckTests(String) to String { if (bvar) {} } }"; - var TEST6 = " abstractAndClass Test { function test() { @@ -75,7 +69,6 @@ abstract SimplifyBooleanExpressionCheckTests(String) to String { if (!bvar) {} } }"; - var TEST7 = " abstractAndClass Test { @SuppressWarnings('checkstyle:SimplifyBooleanExpression') diff --git a/test/checks/coding/SimplifyBooleanReturnCheckTest.hx b/test/checks/coding/SimplifyBooleanReturnCheckTest.hx index c857f3ba..0982b185 100644 --- a/test/checks/coding/SimplifyBooleanReturnCheckTest.hx +++ b/test/checks/coding/SimplifyBooleanReturnCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.SimplifyBooleanReturnCheck; class SimplifyBooleanReturnCheckTest extends CheckTestCase { - static inline var MSG_SIMPLIFY:String = "Conditional logic can be removed"; @Test @@ -32,7 +31,6 @@ abstract SimplifyBooleanReturnCheckTests(String) to String { else return true; } }"; - var TEST2 = " abstractAndClass Test { function test() { @@ -40,7 +38,6 @@ abstract SimplifyBooleanReturnCheckTests(String) to String { return a; } }"; - var TEST3 = " abstractAndClass Test { function test() { diff --git a/test/checks/coding/TraceCheckTest.hx b/test/checks/coding/TraceCheckTest.hx index 493b33d6..0ea6fe82 100644 --- a/test/checks/coding/TraceCheckTest.hx +++ b/test/checks/coding/TraceCheckTest.hx @@ -4,7 +4,6 @@ import checkstyle.SeverityLevel; import checkstyle.checks.coding.TraceCheck; class TraceCheckTest extends CheckTestCase { - static inline var MSG_TRACE_DETECTED:String = "Trace detected"; @Test @@ -39,14 +38,12 @@ abstract TraceCheckTests(String) to String { trace('test'); } }"; - var TRACE_VAR = " abstractAndClass Test { function a(x) { trace(x); } }"; - var TRACE_SUPPRESSED = " abstractAndClass Test { @SuppressWarnings('checkstyle:Trace') @@ -55,13 +52,11 @@ abstract TraceCheckTests(String) to String { trace('test'); } }"; - var TRACE_FUNCTION = " abstractAndClass Test { function trace(x) { } }"; - var CUSTOM_TRACE = " abstractAndClass Test { function equals() { diff --git a/test/checks/coding/UnusedLocalVarCheckTest.hx b/test/checks/coding/UnusedLocalVarCheckTest.hx index 4635e897..3be46984 100644 --- a/test/checks/coding/UnusedLocalVarCheckTest.hx +++ b/test/checks/coding/UnusedLocalVarCheckTest.hx @@ -3,7 +3,6 @@ package checks.coding; import checkstyle.checks.coding.UnusedLocalVarCheck; class UnusedLocalVarCheckTest extends CheckTestCase { - static inline var MSG_UNUSED_VAR_INDEX:String = "Unused local variable index"; @Test @@ -42,7 +41,6 @@ abstract UnusedLocalVarCheckTests(String) to String { }); } }"; - var UNUSED_INDEX = " abstractAndClass Test { // index @@ -51,7 +49,6 @@ abstract UnusedLocalVarCheckTests(String) to String { var index:Int; } }"; - var UNUSED_INDEX2 = " abstractAndClass Test { public function a() { @@ -60,7 +57,6 @@ abstract UnusedLocalVarCheckTests(String) to String { }); } }"; - var STRING_INTERPOLATION = " abstractAndClass Test { function a() { @@ -75,7 +71,6 @@ abstract UnusedLocalVarCheckTests(String) to String { trace ('${index4}'); } }"; - var STRING_INTERPOLATION_UNUSED = " abstractAndClass Test { function a() { diff --git a/test/checks/coding/VariableInitialisationCheckTest.hx b/test/checks/coding/VariableInitialisationCheckTest.hx index 9f7800a0..1efba73b 100644 --- a/test/checks/coding/VariableInitialisationCheckTest.hx +++ b/test/checks/coding/VariableInitialisationCheckTest.hx @@ -3,11 +3,9 @@ package checks.coding; import checkstyle.checks.coding.VariableInitialisationCheck; class VariableInitialisationCheckTest extends CheckTestCase { - @Test public function testVar() { - assertMsg(new VariableInitialisationCheck(), TEST1, - 'Invalid variable "_a" initialisation (move initialisation to constructor or function)'); + assertMsg(new VariableInitialisationCheck(), TEST1, 'Invalid variable "_a" initialisation (move initialisation to constructor or function)'); } @Test @@ -32,14 +30,12 @@ abstract VariableInitialisationCheckTests(String) to String { public function new() {} }"; - var TEST2 = " abstractAndClass Test { static inline var TEST:Int = 1; public function new() {} }"; - var TEST3 = " @:enum abstract Test(Int) { diff --git a/test/checks/comments/DocCommentStyleCheckTest.hx b/test/checks/comments/DocCommentStyleCheckTest.hx index e679fe2d..f8ff94f2 100644 --- a/test/checks/comments/DocCommentStyleCheckTest.hx +++ b/test/checks/comments/DocCommentStyleCheckTest.hx @@ -3,7 +3,6 @@ package checks.comments; import checkstyle.checks.comments.DocCommentStyleCheck; class DocCommentStyleCheckTest extends CheckTestCase { - static inline var MSG_SHOULD_USE_ONE_STAR:String = "Comment should use '/*…*/'"; static inline var MSG_SHOULD_USE_TWO_STARS:String = "Comment should use '/**…**/'"; static inline var MSG_SHOULD_NOT_START_WITH_STAR:String = "Comment lines should not start with '*'"; @@ -57,35 +56,30 @@ abstract DocCommentStyleCheckTests(String) to String { **/ class Test {} "; - var ONE_STAR_NO_STAR_ONE_STAR = " /* comment */ class Test {} "; - var ONE_STAR_ONE_STAR_ONE_STAR = " /* * comment */ class Test {} "; - var TWO_STAR_ONE_STAR_TWO_STAR = " /** * comment **/ class Test {} "; - var TWO_STAR_TWO_STARS_TWO_STAR = " /** ** comment **/ class Test {} "; - var MANY_STARS_NO_STAR_MANY_STARS = " /****************** comment diff --git a/test/checks/comments/FieldDocCommentCheckTest.hx b/test/checks/comments/FieldDocCommentCheckTest.hx index 7489176a..bf89b6d4 100644 --- a/test/checks/comments/FieldDocCommentCheckTest.hx +++ b/test/checks/comments/FieldDocCommentCheckTest.hx @@ -3,7 +3,6 @@ package checks.comments; import checkstyle.checks.comments.FieldDocCommentCheck; class FieldDocCommentCheckTest extends CheckTestCase { - static inline var MSG_DOC_FUNC8:String = 'Field "func8" should have documentation'; static inline var MSG_DOC_FUNC4:String = 'Field "func4" should have documentation'; static inline var MSG_DOC_PARAM1_FUNC8:String = 'Documentation for parameter "param1" of field "func8" missing'; @@ -231,7 +230,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function toString():String {} } "; - var NO_CLASS_FIELDS_COMMENTED = " class Test2 { var field1:String; @@ -248,7 +246,6 @@ abstract FieldDocCommentCheckTests(String) to String { override public function func9(param1:String):String {} } "; - var ONLY_PUBLIC_CLASS_FIELDS_COMMENTED = " class Test2 { var field1:String; @@ -265,7 +262,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String):String {} } "; - var ONLY_PRIVATE_CLASS_FIELDS_COMMENTED = " class Test2 { /** @@ -282,7 +278,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String):String {} } "; - var EMPTY_COMMENT = " class Test2 { /* @@ -297,7 +292,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8():Void {} } "; - var EMPTY_COMMENT_3 = " class Test2 { /** @@ -306,7 +300,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8():Void {} } "; - var MISSING_RETURN = " class Test2 { /** @@ -316,7 +309,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String):String {} } "; - var MISSING_PARAM = " class Test2 { /** @@ -326,7 +318,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String):String {} } "; - var ABSTRACT = " abstract Test(String) { /** @@ -337,7 +328,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String):String {} } "; - var ENUM = " enum Test { /** @@ -346,7 +336,6 @@ abstract FieldDocCommentCheckTests(String) to String { FIELD1; } "; - var INTERFACE = " interface Test { /** @@ -357,7 +346,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String):String; } "; - var TYPEDEF = " typedef Test = { /** @@ -366,7 +354,6 @@ abstract FieldDocCommentCheckTests(String) to String { var field1:String; } "; - var WRONG_PARAM_ORDER = " class Test2 { /** @@ -378,7 +365,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String, param2:String):String {} } "; - var NO_PARAM_TEXT = " class Test2 { /** @@ -389,7 +375,6 @@ abstract FieldDocCommentCheckTests(String) to String { public function func8(param1:String):String {} } "; - var EMPTY_RETURN = " class Test2 { /** diff --git a/test/checks/comments/TODOCommentCheckTest.hx b/test/checks/comments/TODOCommentCheckTest.hx index 467055a9..40877c89 100644 --- a/test/checks/comments/TODOCommentCheckTest.hx +++ b/test/checks/comments/TODOCommentCheckTest.hx @@ -4,7 +4,6 @@ import checkstyle.SeverityLevel; import checkstyle.checks.comments.TODOCommentCheck; class TODOCommentCheckTest extends CheckTestCase { - @Test public function testTODO() { var check = new TODOCommentCheck(); @@ -62,37 +61,31 @@ abstract TODOCommentCheckTests(String) to String { // TODO: remove test public override function test() {} }"; - var TEST2 = " class Test { // FIXME remove test public override function test() {} }"; - var TEST3 = " class Test { // HACK remove test public override function test() {} }"; - var TEST4 = " class Test { // BUG #171: remove test public override function test() {} }"; - var TEST5 = " class Test { // XXX remove test public override function test() {} }"; - var TEST6 = " class Test { var a:String = 'TODO: remove test'; public override function test() {} }"; - var TEST7 = " class Test { function test() { diff --git a/test/checks/comments/TypeDocCommentCheckTest.hx b/test/checks/comments/TypeDocCommentCheckTest.hx index cc65bc38..bbfda710 100644 --- a/test/checks/comments/TypeDocCommentCheckTest.hx +++ b/test/checks/comments/TypeDocCommentCheckTest.hx @@ -3,7 +3,6 @@ package checks.comments; import checkstyle.checks.comments.TypeDocCommentCheck; class TypeDocCommentCheckTest extends CheckTestCase { - @Test public function testDefault() { var check = new TypeDocCommentCheck(); @@ -82,7 +81,6 @@ abstract TypeDocCommentCheckTests(String) to String { **/ typedef TTest = {} "; - var EMPTY_COMMENTS = " /** @@ -109,7 +107,6 @@ abstract TypeDocCommentCheckTests(String) to String { **/ typedef TTest = {} "; - var EMPTY_COMMENTS_2 = " /** **/ @@ -131,7 +128,6 @@ abstract TypeDocCommentCheckTests(String) to String { **/ typedef TTest = {} "; - var EMPTY_COMMENTS_3 = " /* @@ -158,7 +154,6 @@ abstract TypeDocCommentCheckTests(String) to String { */ typedef TTest = {} "; - var NO_COMMENTS = " abstract ATest {} class CTest {} diff --git a/test/checks/design/EmptyPackageCheckTest.hx b/test/checks/design/EmptyPackageCheckTest.hx index 29045dcb..1be8e0a8 100644 --- a/test/checks/design/EmptyPackageCheckTest.hx +++ b/test/checks/design/EmptyPackageCheckTest.hx @@ -3,7 +3,6 @@ package checks.design; import checkstyle.checks.design.EmptyPackageCheck; class EmptyPackageCheckTest extends CheckTestCase { - @Test public function testEmptyPackage() { assertMsg(new EmptyPackageCheck(), TEST1, "Found empty package"); @@ -34,14 +33,12 @@ abstract EmptyPackageCheckTests(String) to String { class Test { public function new() {} }"; - var TEST2 = " package checks.test; class Test { public function new() {} }"; - var TEST3 = " class Test { public function new() {} diff --git a/test/checks/design/InterfaceCheckTest.hx b/test/checks/design/InterfaceCheckTest.hx index a92e0d0f..4ed7686e 100644 --- a/test/checks/design/InterfaceCheckTest.hx +++ b/test/checks/design/InterfaceCheckTest.hx @@ -3,7 +3,6 @@ package checks.design; import checkstyle.checks.design.InterfaceCheck; class InterfaceCheckTest extends CheckTestCase { - static inline var PROPERTIES_MSG:String = "Properties are not allowed in interfaces"; static inline var MARKER_MSG:String = "Marker interfaces are not allowed"; @@ -43,15 +42,12 @@ abstract InterfaceCheckTests(String) to String { interface IComponentController { var a:Int = 1; }"; - var TEST2 = " interface IComponentController {}"; - var TEST3 = " interface IComponentController { function init():Void; }"; - var TEST4 = " interface IComponentController { var a:Int; diff --git a/test/checks/design/UnnecessaryConstructorCheckTest.hx b/test/checks/design/UnnecessaryConstructorCheckTest.hx index 0a22a00c..701e142e 100644 --- a/test/checks/design/UnnecessaryConstructorCheckTest.hx +++ b/test/checks/design/UnnecessaryConstructorCheckTest.hx @@ -3,7 +3,6 @@ package checks.design; import checkstyle.checks.design.UnnecessaryConstructorCheck; class UnnecessaryConstructorCheckTest extends CheckTestCase { - @Test public function testWithConstructor() { assertMsg(new UnnecessaryConstructorCheck(), TEST1, "Unnecessary constructor found"); @@ -56,7 +55,6 @@ abstract UnnecessaryConstructorCheckTests(String) to String { public static function walkFile() {} static function test() {} }"; - var TEST2 = " class Test { static var a:Int = 1; @@ -64,7 +62,6 @@ abstract UnnecessaryConstructorCheckTests(String) to String { public static function walkFile() {} static function test() {} }"; - var TEST3 = " class Test { var loc:Float; @@ -77,7 +74,6 @@ abstract UnnecessaryConstructorCheckTests(String) to String { static function test() {} }"; - var TEST4 = " class Test { var loc:Float; @@ -92,7 +88,6 @@ abstract UnnecessaryConstructorCheckTests(String) to String { public function test2(){} }"; - var TEST5 = " class Test { public function new() {} @@ -100,12 +95,10 @@ abstract UnnecessaryConstructorCheckTests(String) to String { static var a:Int = 1; static inline var b:Int = 1; }"; - var TEST6 = " class Test { public function new() {} }"; - var TEST_STATIC_ONLY_WITH_NEW = " class Test { @@ -116,7 +109,6 @@ abstract UnnecessaryConstructorCheckTests(String) to String { VAR1 = new String(); } }"; - var TEST_CHILD_CLASS = " class Test extends Base { diff --git a/test/checks/imports/AvoidStarImportCheckTest.hx b/test/checks/imports/AvoidStarImportCheckTest.hx index 8b4c53c6..65fc367d 100644 --- a/test/checks/imports/AvoidStarImportCheckTest.hx +++ b/test/checks/imports/AvoidStarImportCheckTest.hx @@ -3,7 +3,6 @@ package checks.imports; import checkstyle.checks.imports.AvoidStarImportCheck; class AvoidStarImportCheckTest extends CheckTestCase { - static inline var MSG_STAR_IMPORT:String = 'Using the ".*" form of import should be avoided'; @Test @@ -36,7 +35,6 @@ abstract AvoidStarImportCheckTests(String) to String { class Test { public function new() {} }"; - var STAR_IMPORT = " package haxe.checkstyle; @@ -49,12 +47,10 @@ abstract AvoidStarImportCheckTests(String) to String { class Test { public function new() {} }"; - var CONDITIONAL_STAR_IMPORT_ISSUE_160 = " #if macro import haxe.macro.*; #end"; - var CONDITIONAL_ELSEIF_STAR_IMPORT = " #if macro import haxe.macro.Type; @@ -70,7 +66,6 @@ abstract AvoidStarImportCheckTests(String) to String { #end #end import haxe.macro.Type;"; - var CONDITIONAL_ELSE_STAR_IMPORT = " #if macro import haxe.macro.Type; diff --git a/test/checks/imports/UnusedImportCheckTest.hx b/test/checks/imports/UnusedImportCheckTest.hx index deaa4062..86368dc5 100644 --- a/test/checks/imports/UnusedImportCheckTest.hx +++ b/test/checks/imports/UnusedImportCheckTest.hx @@ -3,7 +3,6 @@ package checks.imports; import checkstyle.checks.imports.UnusedImportCheck; class UnusedImportCheckTest extends CheckTestCase { - static inline var MSG_UNUSED:String = 'Unused import "haxe.checkstyle.Check3" detected'; static inline var MSG_NAME_REUSED:String = 'Unused import "haxe.checkstyle.Check" detected'; static inline var MSG_DUPLICATE:String = 'Duplicate import "haxe.checkstyle.Check2" detected'; @@ -49,10 +48,7 @@ class UnusedImportCheckTest extends CheckTestCase { assertMsg(check, UNUSED_IMPORT_TYPE_MAP, MSG_UNUSED_TYPEMAP); check.moduleTypeMap = { - "checkstyle.checks.Checker": [ - "CheckBase", - "UnusedImportCheck" - ] + "checkstyle.checks.Checker": ["CheckBase", "UnusedImportCheck"] }; assertNoMsg(check, SAME_PACKAGE_TYPE_MAP); assertNoMsg(check, IMPORT_TYPE_MAP); @@ -103,7 +99,6 @@ abstract UnusedImportCheckTests(String) to String { trace ('${Check5.debug()} ${blah.xxx}'); } }"; - var IMPORT_NOT_USED = " package checkstyle.test; @@ -118,7 +113,6 @@ abstract UnusedImportCheckTests(String) to String { Check2.test(); } }"; - var DUPLICATE_IMPORT = " package checkstyle.test; @@ -133,7 +127,6 @@ abstract UnusedImportCheckTests(String) to String { Check2.test(); } }"; - var IMPORT_NAME_REUSED = " package checkstyle.test; @@ -157,7 +150,6 @@ abstract UnusedImportCheckTests(String) to String { } typedef Check = Dynamic; "; - var TOP_LEVEL_IMPORT = " package checkstyle.test; @@ -168,7 +160,6 @@ abstract UnusedImportCheckTests(String) to String { public function new() { } }"; - var IMPORT_BASE_CLASS = " package checkstyle.test; @@ -179,7 +170,6 @@ abstract UnusedImportCheckTests(String) to String { public function new() {} }"; - var IMPORT_AS = " package checkstyle.test; @@ -187,21 +177,18 @@ abstract UnusedImportCheckTests(String) to String { import haxe.checkstyle.Check2 in Base2; class Test extends Base implements Base2 {}"; - var UNUSED_IMPORT_AS = " package checkstyle.test; import haxe.checkstyle.Check as Base; class Test {}"; - var UNUSED_IMPORT_IN = " package checkstyle.test; import haxe.checkstyle.Check in Base; abstractAndClass Test {}"; - var IMPORT_IN_STATIC_FUNC = " import String.fromCharCode in f; @@ -211,7 +198,6 @@ abstract UnusedImportCheckTests(String) to String { var c1 = f(65); } }"; - var UNUSED_IMPORT_IN_STATIC_FUNC = " import String.fromCharCode in f; @@ -219,7 +205,6 @@ abstract UnusedImportCheckTests(String) to String { static function main() {} }"; - var SAME_PACKAGE_IMPORT = " package checkstyle.checks; @@ -232,7 +217,6 @@ abstract UnusedImportCheckTests(String) to String { return new UnusedImportCheck (); } }"; - var SAME_PACKAGE_TYPE_MAP = " package checkstyle.checks; @@ -244,7 +228,6 @@ abstract UnusedImportCheckTests(String) to String { return new UnusedImportCheck (); } }"; - var IMPORT_TYPE_MAP = " package checkstyle.test; @@ -256,7 +239,6 @@ abstract UnusedImportCheckTests(String) to String { return new UnusedImportCheck (); } }"; - var UNUSED_IMPORT_TYPE_MAP = " package checkstyle.test; @@ -268,7 +250,6 @@ abstract UnusedImportCheckTests(String) to String { return new OtherCheck (); } }"; - var STRING_INTERPOL = " package checkstyle.test; diff --git a/test/checks/literal/ArrayLiteralCheckTest.hx b/test/checks/literal/ArrayLiteralCheckTest.hx index 0c321dd4..d87bdbf5 100644 --- a/test/checks/literal/ArrayLiteralCheckTest.hx +++ b/test/checks/literal/ArrayLiteralCheckTest.hx @@ -3,7 +3,6 @@ package checks.literal; import checkstyle.checks.literal.ArrayLiteralCheck; class ArrayLiteralCheckTest extends CheckTestCase { - @Test public function testWrongArrayInstantiation() { assertMsg(new ArrayLiteralCheck(), TEST1, 'Bad array instantiation, use the array literal notation "[]" which is shorter and cleaner'); @@ -21,7 +20,6 @@ abstract ArrayLiteralCheckTests(String) to String { abstractAndClass Test { var _arr:Array = new Array(); }"; - var TEST2 = " abstractAndClass Test { var _arr:Array = []; diff --git a/test/checks/literal/ERegLiteralCheckTest.hx b/test/checks/literal/ERegLiteralCheckTest.hx index fb0af7c7..a318c357 100644 --- a/test/checks/literal/ERegLiteralCheckTest.hx +++ b/test/checks/literal/ERegLiteralCheckTest.hx @@ -3,7 +3,6 @@ package checks.literal; import checkstyle.checks.literal.ERegLiteralCheck; class ERegLiteralCheckTest extends CheckTestCase { - @Test public function testCorrectEReg() { assertNoMsg(new ERegLiteralCheck(), TEST2); @@ -31,19 +30,16 @@ abstract ERegLiteralCheckTests(String) to String { abstractAndClass Test { var _reg:EReg = new EReg('test', 'i'); }"; - var TEST2 = " abstractAndClass Test { var _reg:EReg = ~/test/i; }"; - var ISSUE_43 = " abstractAndClass Test { function test() { cast (Type.createInstance(Array, [])); } }"; - var REGEX_WITH_STRING_INTERPOLATION = " abstractAndClass Test { var regex = new EReg('^${pattern}$', 'ig'); diff --git a/test/checks/literal/HexadecimalLiteralCheckTest.hx b/test/checks/literal/HexadecimalLiteralCheckTest.hx index 86fd3931..eca0a445 100644 --- a/test/checks/literal/HexadecimalLiteralCheckTest.hx +++ b/test/checks/literal/HexadecimalLiteralCheckTest.hx @@ -3,7 +3,6 @@ package checks.literal; import checkstyle.checks.literal.HexadecimalLiteralCheck; class HexadecimalLiteralCheckTest extends CheckTestCase { - @Test public function test1() { assertMsg(new HexadecimalLiteralCheck(), TEST1, "Bad hexadecimal literal, use upperCase"); @@ -28,12 +27,10 @@ abstract HexadecimalLiteralCheckTests(String) to String { abstractAndClass Test { var clr = 0xffffff; }"; - var TEST2 = " abstractAndClass Test { var clr = 0x0033FF; }"; - var TEST3 = " abstractAndClass Test { var clr = 0x0033FF; diff --git a/test/checks/literal/MultipleStringLiteralsCheckTest.hx b/test/checks/literal/MultipleStringLiteralsCheckTest.hx index 7ed3ef81..7349b76f 100644 --- a/test/checks/literal/MultipleStringLiteralsCheckTest.hx +++ b/test/checks/literal/MultipleStringLiteralsCheckTest.hx @@ -3,7 +3,6 @@ package checks.literal; import checkstyle.checks.literal.MultipleStringLiteralsCheck; class MultipleStringLiteralsCheckTest extends CheckTestCase { - @Test public function testAllowedMultipleStringLiterals() { var check = new MultipleStringLiteralsCheck(); @@ -55,7 +54,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { c = 'test'; } }"; - var CONSTANT_NOT_COUNTED = " class Test { static var a:String = 'xml'; @@ -64,7 +62,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { b = 'xml'; } }"; - var THREE_XML = " class Test { var a:String = 'xml'; @@ -72,7 +69,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { a = 'xml'; } }"; - var THREE_SPACE = " class Test { var a:String = ' '; @@ -80,7 +76,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { a = ' '; } }"; - var THREE_XML_SWITCH = " class Test { var a:String = 'xml'; @@ -91,7 +86,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { } } }"; - var SINGLE_CHARS = " class Test { public function new() { @@ -99,7 +93,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { b = 'b' + 'b' + 'a' + 'b' + 'b'; } }"; - var OBJECT_FIELD_KEYS_ISSUE_116 = " class Test { function foo() { @@ -116,7 +109,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { ]; } }"; - var OBJECT_FIELD_VALUES_ISSUE_116 = " class Test { function foo() { @@ -128,7 +120,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { ]; } }"; - var INTERPOLATION_ISSUE_109 = " class Test { function foo() { @@ -148,7 +139,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { trace('$value is ${i++} $i'); } }"; - var NO_INTERPOLATION_ISSUE_109 = " class Test { function foo() { @@ -156,7 +146,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { trace('value $$is i'); } }"; - var NO_INTERPOLATION_AT_START_ISSUE_109 = " class Test { function foo() { @@ -164,7 +153,6 @@ abstract MultipleStringLiteralsCheckTests(String) to String { trace('$$is i'); } }"; - var EXAGGERATION_ISSUE_318 = " class Test { function foo() { @@ -174,8 +162,7 @@ abstract MultipleStringLiteralsCheckTests(String) to String { System.storage.remove('user.name'); } }"; - - var SUPPRESSION = " + var SUPPRESSION = " class Test { function foo() { name = new Value(System.storage.get('user.name'), function(to, _) System.storage.set('user.name', to)); diff --git a/test/checks/literal/StringLiteralCheckTest.hx b/test/checks/literal/StringLiteralCheckTest.hx index 0c2b563a..a1f0f391 100644 --- a/test/checks/literal/StringLiteralCheckTest.hx +++ b/test/checks/literal/StringLiteralCheckTest.hx @@ -3,7 +3,6 @@ package checks.literal; import checkstyle.checks.literal.StringLiteralCheck; class StringLiteralCheckTest extends CheckTestCase { - @Test public function testOnlySingleQuote() { var check = new StringLiteralCheck(); @@ -93,7 +92,6 @@ abstract StringLiteralCheckTests(String) to String { c = 'test'; } }"; - var SINGLE_QUOTE_WITH_EXCEPTION = " class Test { static var a:String = 'check'; @@ -103,7 +101,6 @@ abstract StringLiteralCheckTests(String) to String { c = \"test 'xml' \"; } }"; - var DOUBLE_QUOTE = ' class Test { static var a:String = "check"; @@ -112,7 +109,6 @@ abstract StringLiteralCheckTests(String) to String { c = "test"; } }'; - var DOUBLE_QUOTE_WITH_EXCEPTION = ' class Test { static var a:String = "check"; @@ -122,7 +118,6 @@ abstract StringLiteralCheckTests(String) to String { c = \'test "xml" \'; } }'; - var INTERPOLATION = " class Test { function foo() { @@ -142,7 +137,6 @@ abstract StringLiteralCheckTests(String) to String { trace('$value is ${i++} $i'); } }"; - var NO_INTERPOLATION = " class Test { function foo() { diff --git a/test/checks/meta/RedundantAccessMetaCheckTest.hx b/test/checks/meta/RedundantAccessMetaCheckTest.hx index 3a5b5c44..b27c7d86 100644 --- a/test/checks/meta/RedundantAccessMetaCheckTest.hx +++ b/test/checks/meta/RedundantAccessMetaCheckTest.hx @@ -3,7 +3,6 @@ package checks.meta; import checkstyle.checks.meta.RedundantAccessMetaCheck; class RedundantAccessMetaCheckTest extends CheckTestCase { - @Test public function testRedundantAccess() { var check = new RedundantAccessMetaCheck(); @@ -42,7 +41,6 @@ abstract RedundantAccessMetaCheckTests(String) to String { @:access(pack.age.Test2) function test() {} }"; - var REDUNDANT_ACCESS = " @:access(pack.age.Test) abstractAndClass Test { @@ -50,7 +48,6 @@ abstract RedundantAccessMetaCheckTests(String) to String { @:access(pack.age.Test) function test() {} }"; - var REDUNDANT_ACCESS_PACKAGE = " @:access(pack.age) abstractAndClass Test { diff --git a/test/checks/meta/RedundantAllowMetaCheckTest.hx b/test/checks/meta/RedundantAllowMetaCheckTest.hx index 7a9394c7..b6100ba1 100644 --- a/test/checks/meta/RedundantAllowMetaCheckTest.hx +++ b/test/checks/meta/RedundantAllowMetaCheckTest.hx @@ -3,7 +3,6 @@ package checks.meta; import checkstyle.checks.meta.RedundantAllowMetaCheck; class RedundantAllowMetaCheckTest extends CheckTestCase { - @Test public function testRedundantAccess() { var check = new RedundantAllowMetaCheck(); @@ -45,7 +44,6 @@ abstract RedundantAllowMetaCheckTests(String) to String { @:access(pack.age.Test2) function test() {} }"; - var REDUNDANT_ACCESS = " @:allow(pack.age.Test) abstractAndClass Test { @@ -53,7 +51,6 @@ abstract RedundantAllowMetaCheckTests(String) to String { @:allow(pack.age.Test) function test() {} }"; - var REDUNDANT_ACCESS_PACKAGE = " @:allow(pack.age) abstractAndClass Test { @@ -61,7 +58,6 @@ abstract RedundantAllowMetaCheckTests(String) to String { @:allow(pack.age.Test) function test() {} }"; - var REDUNDANT_ACCESS_PUBLIC = " abstractAndClass Test { diff --git a/test/checks/metrics/CyclomaticComplexityCheckTest.hx b/test/checks/metrics/CyclomaticComplexityCheckTest.hx index 3b2dff46..a6f645ff 100644 --- a/test/checks/metrics/CyclomaticComplexityCheckTest.hx +++ b/test/checks/metrics/CyclomaticComplexityCheckTest.hx @@ -3,20 +3,13 @@ package checks.metrics; import checkstyle.checks.metrics.CyclomaticComplexityCheck; class CyclomaticComplexityCheckTest extends CheckTestCase { - @Test public function testCorrectNaming() { var check = new CyclomaticComplexityCheck(); - check.thresholds = [ - { severity : "WARNING", complexity : 1 }, - { severity : "ERROR", complexity : 2 } - ]; + check.thresholds = [{severity: "WARNING", complexity: 1}, {severity: "ERROR", complexity: 2}]; assertMsg(check, TEST, 'Method "test" is too complex (score: 2).'); - check.thresholds = [ - { severity : "IGNORE", complexity : 1 }, - { severity : "IGNORE", complexity : 2 } - ]; + check.thresholds = [{severity: "IGNORE", complexity: 1}, {severity: "IGNORE", complexity: 2}]; assertNoMsg(check, TEST); } } diff --git a/test/checks/modifier/PublicAccessorCheckTest.hx b/test/checks/modifier/PublicAccessorCheckTest.hx index 4085a3bd..c5bc92a5 100644 --- a/test/checks/modifier/PublicAccessorCheckTest.hx +++ b/test/checks/modifier/PublicAccessorCheckTest.hx @@ -3,7 +3,6 @@ package checks.modifier; import checkstyle.checks.modifier.PublicAccessorCheck; class PublicAccessorCheckTest extends CheckTestCase { - static inline var ERROR:String = "Accessor method should not be public"; @Test @@ -29,32 +28,26 @@ abstract PublicAccessorCheckTests(String) to String { public function _set_test() {} public function _get_test() {} }"; - var PUBLIC_GETTER = " abstractAndClass Test { public function get_test() {} }"; - var PUBLIC_SETTER = " abstractAndClass Test { override inline public function set_test() {} }"; - var IMPLICITLY_PUBLIC_GETTER = " @:publicFields class Test { function get_test() {} }"; - var IMPLICITLY_PUBLIC_SETTER = " @:publicFields class Test { function set_test() {} }"; - var INTERFACE_PUBLIC_GETTER = " interface ITest { function get_test() {} }"; - var INTERFACE_PUBLIC_SETTER = " interface ITest { function set_test() {} diff --git a/test/checks/modifier/RedundantModifierCheckTest.hx b/test/checks/modifier/RedundantModifierCheckTest.hx index 922216d7..920ffa7c 100644 --- a/test/checks/modifier/RedundantModifierCheckTest.hx +++ b/test/checks/modifier/RedundantModifierCheckTest.hx @@ -3,7 +3,6 @@ package checks.modifier; import checkstyle.checks.modifier.RedundantModifierCheck; class RedundantModifierCheckTest extends CheckTestCase { - @Test public function testCorrectUsage() { assertNoMsg(new RedundantModifierCheck(), TEST); @@ -119,86 +118,71 @@ abstract RedundantModifierCheckTests(String) to String { public function test(){} }"; - var TEST1 = " abstractAndClass Test { private var a:Int; }"; - var TEST2 = " interface Test { public var a:Int; }"; - var TEST3 = " interface Test { var a:Int; }"; - var TEST4 = " @:publicFields class Test { private function foo() {} }"; - var TEST5 = " @:publicFields class Test { public function foo() {} }"; - var TEST6 = " @:publicFields class Test { function foo() {} }"; - var TEST7 = " @:enum abstract Test(Int) { public var value = 0; }"; - var TEST8 = " @:enum abstract Test(Int) { var value = 0; }"; - var TEST9 = " @:enum abstract Test(Int) { private static inline var CONSTANT = 0; }"; - var TEST10 = " @:enum abstract Test(Int) { static inline var CONSTANT = 0; }"; - var TEST11 = " @:enum abstract Test(Int) { private function foo() {} }"; - var TEST12 = " @:enum abstract Test(Int) { function foo() {} }"; - var TEST13 = " abstractAndClass Test { function new() {} }"; - var TEST14 = " abstractAndClass Test { private function new() {} }"; - var TEST15 = " abstractAndClass Test { public function new() {} diff --git a/test/checks/naming/CatchParameterNameCheckTest.hx b/test/checks/naming/CatchParameterNameCheckTest.hx index 735a4266..d7763975 100644 --- a/test/checks/naming/CatchParameterNameCheckTest.hx +++ b/test/checks/naming/CatchParameterNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.CatchParameterNameCheck; class CatchParameterNameCheckTest extends CheckTestCase { - @Test public function testCorrectNaming() { var check = new CatchParameterNameCheck(); @@ -35,7 +34,6 @@ abstract CatchParameterNameCheckTests(String) to String { catch(e:String) {} } }"; - var TEST2 = " class Test { public function test() { diff --git a/test/checks/naming/ConstantNameCheckTest.hx b/test/checks/naming/ConstantNameCheckTest.hx index 10f0b4f4..cf784252 100644 --- a/test/checks/naming/ConstantNameCheckTest.hx +++ b/test/checks/naming/ConstantNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.ConstantNameCheck; class ConstantNameCheckTest extends CheckTestCase { - @Test public function testCorrectNaming() { var check = new ConstantNameCheck(); @@ -84,14 +83,12 @@ abstract ConstantNameCheckTests(String) to String { @SuppressWarnings('checkstyle:ConstantName') static var count7:Int = 1; }"; - var TEST1 = " class Test { static var Count:Int = 1; public function test() { } }"; - var TEST2 = " class Test { static inline var Count:Int = 1; @@ -99,7 +96,6 @@ abstract ConstantNameCheckTests(String) to String { var Count:Int; } }"; - var TEST3 = " extern class Test { static var Count:Int = 1; diff --git a/test/checks/naming/ListenerNameCheckTest.hx b/test/checks/naming/ListenerNameCheckTest.hx index 7a7beba4..700876b0 100644 --- a/test/checks/naming/ListenerNameCheckTest.hx +++ b/test/checks/naming/ListenerNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.ListenerNameCheck; class ListenerNameCheckTest extends CheckTestCase { - @Test public function testCorrectListenerName() { assertNoMsg(new ListenerNameCheck(), TEST); @@ -28,7 +27,6 @@ abstract ListenerNameCheckTests(String) to String { function _onUpdate() {} }"; - var TEST1 = " abstractAndClass Test { var a:Stage; diff --git a/test/checks/naming/LocalVariableNameCheckTest.hx b/test/checks/naming/LocalVariableNameCheckTest.hx index 231f96a9..5fac92fd 100644 --- a/test/checks/naming/LocalVariableNameCheckTest.hx +++ b/test/checks/naming/LocalVariableNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.LocalVariableNameCheck; class LocalVariableNameCheckTest extends CheckTestCase { - @Test public function testCorrectNaming() { var check = new LocalVariableNameCheck(); @@ -78,21 +77,18 @@ abstract LocalVariableNameCheckTests(String) to String { var Count1:Int; }; }"; - var TEST1 = " class Test { public function test() { var Count:Int = 1; } }"; - var TEST3 = " typedef Test = { public function test() { var Count:Int; } }"; - var TEST4 = " extern class Test { public function test() { diff --git a/test/checks/naming/MemberNameCheckTest.hx b/test/checks/naming/MemberNameCheckTest.hx index 8fb68229..15916867 100644 --- a/test/checks/naming/MemberNameCheckTest.hx +++ b/test/checks/naming/MemberNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.MemberNameCheck; class MemberNameCheckTest extends CheckTestCase { - @Test public function testCorrectNaming() { var check = new MemberNameCheck(); @@ -229,26 +228,22 @@ abstract MemberNameCheckTests(String) to String { @SuppressWarnings('checkstyle:MemberName') var COUNT6:Int = 1; }"; - var TEST1 = " class Test { public var Count:Int = 1; public function test() { } }"; - var TEST2 = " class Test { var Count:Int = 1; public function test() { } }"; - var TEST3 = " typedef Test = { var Count:Int; }"; - var TEST4 = " extern class Test { var Count:Int = 1; @@ -256,19 +251,16 @@ abstract MemberNameCheckTests(String) to String { public function test() { } }"; - var TEST5 = " enum Test { VALUE_TEST_; VALUE_TEST; }"; - var TEST6 = " enum Test { VALUE_; VALUE; }"; - var ABSTRACT_FIELDS = " @:enum abstract MyAbstract(Int) from Int to Int { @@ -280,12 +272,10 @@ abstract MemberNameCheckTests(String) to String { static public function doSomething () : Void trace(NORMAL_CONST); }"; - var PROPERTY_NAME = " class Test { public var Example(default, null):Int; }"; - var DEFINE_COMBINATIONS = " class Test { #if flash diff --git a/test/checks/naming/MethodNameCheckTest.hx b/test/checks/naming/MethodNameCheckTest.hx index 7c24e8cb..1552fd75 100644 --- a/test/checks/naming/MethodNameCheckTest.hx +++ b/test/checks/naming/MethodNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.MethodNameCheck; class MethodNameCheckTest extends CheckTestCase { - @Test public function testCorrectNaming() { var check = new MethodNameCheck(); @@ -146,14 +145,12 @@ abstract MethodNameCheckTests(String) to String { function test() {}; function testName() {}; }"; - var TEST1 = " abstractAndClass Test { static public function Test() {} public function Test2() {} static inline public function Test3() {} }"; - var TEST2 = " abstractAndClass Test { static public function Test() {} @@ -161,17 +158,14 @@ abstract MethodNameCheckTests(String) to String { public function Test2() {} function Test3() {} }"; - var TEST3 = " typedef Test = { public function Test() {} }"; - var TEST4 = " extern class Test { public function Test() {} }"; - var TEST5 = " abstractAndClass Test { static function Test() {} diff --git a/test/checks/naming/ParameterNameCheckTest.hx b/test/checks/naming/ParameterNameCheckTest.hx index 38ab6a77..a7c39055 100644 --- a/test/checks/naming/ParameterNameCheckTest.hx +++ b/test/checks/naming/ParameterNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.ParameterNameCheck; class ParameterNameCheckTest extends CheckTestCase { - @Test public function testCorrectNaming() { var check = new ParameterNameCheck(); @@ -70,31 +69,26 @@ abstract ParameterNameCheckTests(String) to String { function test(param1:Int, paramName:String) { } }"; - var TEST1 = " abstractAndClass Test { public function test(Count:Int) { } }"; - var TEST2 = " abstractAndClass Test { public function test() { } }"; - var TEST3 = " typedef Test = { function test(param1:Int, ParamName:String) { } }"; - var TEST4 = " extern class Test { public function test(Param1:Int) { } }"; - var TEST5 = " enum Test { VALUE(ParamName:String); diff --git a/test/checks/naming/TypeNameCheckTest.hx b/test/checks/naming/TypeNameCheckTest.hx index 550c6dbc..a4aeae06 100644 --- a/test/checks/naming/TypeNameCheckTest.hx +++ b/test/checks/naming/TypeNameCheckTest.hx @@ -3,7 +3,6 @@ package checks.naming; import checkstyle.checks.naming.TypeNameCheck; class TypeNameCheckTest extends CheckTestCase { - static inline var FORMAT_CLASS:String = "^C[A-Z][a-z]*$"; @Test @@ -125,20 +124,16 @@ abstract TypeNameCheckTests(String) to String { var count1:Int; var count2:String; }"; - var TEST1 = " abstractAndClass CTest { }"; - var TEST2 = " interface Test { }"; - var TEST3 = " typedef TTest = { var Count:Int; }"; - var TEST4 = " extern class TEST1 { var Count:Int = 1; @@ -146,12 +141,10 @@ abstract TypeNameCheckTests(String) to String { public function test() { } }"; - var TEST5 = " enum EnumTest { VALUE; }"; - var TEST6 = " class Test_ { }"; diff --git a/test/checks/size/FileLengthCheckTest.hx b/test/checks/size/FileLengthCheckTest.hx index 922a080b..5835a225 100644 --- a/test/checks/size/FileLengthCheckTest.hx +++ b/test/checks/size/FileLengthCheckTest.hx @@ -3,7 +3,6 @@ package checks.size; import checkstyle.checks.size.FileLengthCheck; class FileLengthCheckTest extends CheckTestCase { - @Test public function testCorrectLineCount() { assertNoMsg(new FileLengthCheck(), TEST2000); @@ -78,7 +77,6 @@ abstract FileLengthCheckTests(String) to String { \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n // 2000 }"; // 2001 - var TEST2000 = "\n class Test { public function new() { @@ -125,7 +123,6 @@ abstract FileLengthCheckTests(String) to String { \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n // 1999 }"; // 2000 - var TEST41 = "\n class Test { public function new() { @@ -133,7 +130,6 @@ abstract FileLengthCheckTests(String) to String { // 10 20 30 40 49 // 6 \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n\n\n // 40 }"; - var TEST42 = "\n @SuppressWarnings('checkstyle:FileLength') class Test { diff --git a/test/checks/size/LineLengthCheckTest.hx b/test/checks/size/LineLengthCheckTest.hx index 984d1ed7..44eb4b3e 100644 --- a/test/checks/size/LineLengthCheckTest.hx +++ b/test/checks/size/LineLengthCheckTest.hx @@ -3,7 +3,6 @@ package checks.size; import checkstyle.checks.size.LineLengthCheck; class LineLengthCheckTest extends CheckTestCase { - @Test public function testDefaultLineLength() { assertMsg(new LineLengthCheck(), TEST1, "Line is longer than 160 characters (found 178)"); @@ -31,7 +30,6 @@ abstract LineLengthCheckTests(String) to String { var s = 'LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST LONG LINE TEST'; } }"; - var TEST2 = " class Test { public function new() { @@ -46,7 +44,6 @@ abstract LineLengthCheckTests(String) to String { } } }"; - var TEST3 = " class Test { public function new() { diff --git a/test/checks/size/MethodCountCheckTest.hx b/test/checks/size/MethodCountCheckTest.hx index 4a3c47e3..c620e1d2 100644 --- a/test/checks/size/MethodCountCheckTest.hx +++ b/test/checks/size/MethodCountCheckTest.hx @@ -3,7 +3,6 @@ package checks.size; import checkstyle.checks.size.MethodCountCheck; class MethodCountCheckTest extends CheckTestCase { - @Test public function testTotal() { var check = new MethodCountCheck(); @@ -136,7 +135,6 @@ abstract MethodCountCheckTests(String) to String { public function test100() {} public function test101() {} }"; - var TEST2 = " abstractAndClass Test { function test1() {} @@ -149,7 +147,6 @@ abstract MethodCountCheckTests(String) to String { static inline function test8() {} public static inline function test9() {} }"; - var TEST3 = " abstractAndClass Test { public function test1() {} diff --git a/test/checks/size/MethodLengthCheckTest.hx b/test/checks/size/MethodLengthCheckTest.hx index 8f47d72e..10de568c 100755 --- a/test/checks/size/MethodLengthCheckTest.hx +++ b/test/checks/size/MethodLengthCheckTest.hx @@ -3,7 +3,6 @@ package checks.size; import checkstyle.checks.size.MethodLengthCheck; class MethodLengthCheckTest extends CheckTestCase { - @Test public function testWrongMethodLength() { assertMsg(new MethodLengthCheck(), TEST1, "Method `test` length is 354 lines (max allowed is 50)"); @@ -52,7 +51,6 @@ abstract MethodLengthCheckTests(String) to String { \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n } }"; - var TEST2 = " abstractAndClass Test { public function test() { @@ -63,7 +61,6 @@ abstract MethodLengthCheckTests(String) to String { trace('TEST'); } }"; - var TEST3 = " abstractAndClass Test { public function test() { diff --git a/test/checks/size/ParameterNumberCheckTest.hx b/test/checks/size/ParameterNumberCheckTest.hx index a8f20299..71fd1ee6 100644 --- a/test/checks/size/ParameterNumberCheckTest.hx +++ b/test/checks/size/ParameterNumberCheckTest.hx @@ -3,7 +3,6 @@ package checks.size; import checkstyle.checks.size.ParameterNumberCheck; class ParameterNumberCheckTest extends CheckTestCase { - @Test public function testNoParams() { var check = new ParameterNumberCheck(); @@ -69,7 +68,6 @@ abstract ParameterNumberCheckTests(String) to String { return; } }"; - var TEST2 = " abstractAndClass Test { public function test1(param1:Int, @@ -82,7 +80,6 @@ abstract ParameterNumberCheckTests(String) to String { return 3; } }"; - var TEST3 = " abstractAndClass Test { override public function test2(param1:Int, @@ -96,7 +93,6 @@ abstract ParameterNumberCheckTests(String) to String { return; } }"; - var TEST4 = " abstractAndClass Test { public function test3(param1:Int, @@ -105,7 +101,6 @@ abstract ParameterNumberCheckTests(String) to String { return; } }"; - var TEST5 = " interface ITest { public function test4(param1:Int, diff --git a/test/checks/type/AnonymousCheckTest.hx b/test/checks/type/AnonymousCheckTest.hx index 58b89924..7ca86ec3 100644 --- a/test/checks/type/AnonymousCheckTest.hx +++ b/test/checks/type/AnonymousCheckTest.hx @@ -3,7 +3,6 @@ package checks.type; import checkstyle.checks.type.AnonymousCheck; class AnonymousCheckTest extends CheckTestCase { - @Test public function testAnonymousStructureClassVar() { assertMsg(new AnonymousCheck(), TEST1, 'Anonymous structure "anonymous" found, use "typedef"'); @@ -21,7 +20,6 @@ abstract AnonymousCheckTests(String) to String { abstractAndClass Test { var anonymous:{a:Int, b:Int}; }"; - var TEST2 = " abstractAndClass Test { public function new() { diff --git a/test/checks/type/DynamicCheckTest.hx b/test/checks/type/DynamicCheckTest.hx index ee22e998..877fdcea 100644 --- a/test/checks/type/DynamicCheckTest.hx +++ b/test/checks/type/DynamicCheckTest.hx @@ -3,7 +3,6 @@ package checks.type; import checkstyle.checks.type.DynamicCheck; class DynamicCheckTest extends CheckTestCase { - @Test public function testNoDynamic() { var check = new DynamicCheck(); @@ -108,26 +107,22 @@ abstract DynamicCheckTests(String) to String { @SuppressWarnings('checkstyle:Dynamic') typedef Test3b = Array;"; - var TEST1 = " class Test { public var Count:Dynamic = 1; public function test() { } }"; - var TEST2 = " class Test { var Count:Int = 1; public function test():Dynamic { } }"; - var TEST3 = " typedef Test = { var Count:Dynamic; }"; - var TEST4 = " extern class Test { var Count:Int = 1; @@ -135,7 +130,6 @@ abstract DynamicCheckTests(String) to String { public function test(param:Dynamic) { } }"; - var TEST5 = " class Test { var Count:Int = 1; @@ -143,10 +137,8 @@ abstract DynamicCheckTests(String) to String { var test:Dynamic = null; } }"; - var TEST6 = " typedef Test = String -> Dynamic;"; - var ISSUE_43 = " class Test { function test() { diff --git a/test/checks/type/ReturnCheckTest.hx b/test/checks/type/ReturnCheckTest.hx index b503acb7..a6123a8a 100644 --- a/test/checks/type/ReturnCheckTest.hx +++ b/test/checks/type/ReturnCheckTest.hx @@ -3,7 +3,6 @@ package checks.type; import checkstyle.checks.type.ReturnCheck; class ReturnCheckTest extends CheckTestCase { - static inline var MSG_VOID_RETURN:String = 'Redundant "Void" for method "test"'; static inline var MSG_NOT_TEST1_RETURN:String = 'Return type not specified for method "test1"'; static inline var MSG_NOT_TEST2_RETURN:String = 'Return type not specified for method "test2"'; @@ -115,7 +114,6 @@ abstract ReturnCheckTests(String) to String { abstractAndClass Test { public function test():Void {} }"; - var TEST2 = " abstractAndClass Test { public function test1() { @@ -124,7 +122,6 @@ abstract ReturnCheckTests(String) to String { } } }"; - var TEST2A = " abstractAndClass Test { public function test1() { @@ -134,7 +131,6 @@ abstract ReturnCheckTests(String) to String { } } }"; - var TEST2B = " abstractAndClass Test { public function test1() { @@ -146,7 +142,6 @@ abstract ReturnCheckTests(String) to String { } } }"; - var TEST3 = " abstractAndClass Test { public function test2() { @@ -154,14 +149,12 @@ abstract ReturnCheckTests(String) to String { return; } }"; - var TEST4 = " abstractAndClass Test { public function test3():Void { return; } }"; - var TEST5 = " abstractAndClass Test { public function test4() { @@ -171,12 +164,10 @@ abstract ReturnCheckTests(String) to String { return; } }"; - var TEST6 = " extern class Test { function test4():Void; }"; - var TEST_FOR = " abstractAndClass Test { public function test1() { @@ -185,7 +176,6 @@ abstract ReturnCheckTests(String) to String { } } }"; - var TEST_WHILE = " abstractAndClass Test { public function test1() { @@ -194,12 +184,10 @@ abstract ReturnCheckTests(String) to String { } } }"; - var INTERFACE = " interface Test { public function test1(); }"; - var CORRECT_RETURN_ANONYMOUS = " abstractAndClass Test { public function test7() { @@ -209,7 +197,6 @@ abstract ReturnCheckTests(String) to String { return; } }"; - var CORRECT_RETURN = " abstractAndClass Test { public function test1():Int { diff --git a/test/checks/type/TypeCheckTest.hx b/test/checks/type/TypeCheckTest.hx index 770d85f4..abc439c1 100644 --- a/test/checks/type/TypeCheckTest.hx +++ b/test/checks/type/TypeCheckTest.hx @@ -3,7 +3,6 @@ package checks.type; import checkstyle.checks.type.TypeCheck; class TypeCheckTest extends CheckTestCase { - @Test public function testClassVar() { assertMsg(new TypeCheck(), TEST1, 'Variable "_a" type not specified'); @@ -34,18 +33,15 @@ abstract TypeCheckTests(String) to String { @SuppressWarnings('checkstyle:Type') var _b; }"; - var TEST2 = " class Test { static inline var A = 1; }"; - var TEST3 = " @:enum abstract Test(Int) { var VALUE = 0; }"; - var TEST4 = " @:enum abstract Test(Int) { diff --git a/test/checks/whitespace/ArrayAccessCheckTest.hx b/test/checks/whitespace/ArrayAccessCheckTest.hx index 73eef6c6..b5553dd6 100644 --- a/test/checks/whitespace/ArrayAccessCheckTest.hx +++ b/test/checks/whitespace/ArrayAccessCheckTest.hx @@ -3,7 +3,6 @@ package checks.whitespace; import checkstyle.checks.whitespace.ArrayAccessCheck; class ArrayAccessCheckTest extends CheckTestCase { - @Test public function testSpaceBefore() { assertMsg(new ArrayAccessCheck(), TEST1, "Space between array and ["); @@ -46,7 +45,6 @@ abstract ArrayAccessCheckTests(String) to String { a [0] = 1; } }"; - var TEST2 = " class Test { @@ -56,7 +54,6 @@ abstract ArrayAccessCheckTests(String) to String { a[ 0] = 1; } }"; - var TEST3 = " class Test { @@ -66,7 +63,6 @@ abstract ArrayAccessCheckTests(String) to String { a[0 ] = 1; } }"; - var TEST4 = " class Test { @@ -76,7 +72,6 @@ abstract ArrayAccessCheckTests(String) to String { a[ 0 ] = 1; } }"; - var TEST5 = " class Test { diff --git a/test/checks/whitespace/EmptyLinesCheckTest.hx b/test/checks/whitespace/EmptyLinesCheckTest.hx index 4e9be696..a0b0e827 100644 --- a/test/checks/whitespace/EmptyLinesCheckTest.hx +++ b/test/checks/whitespace/EmptyLinesCheckTest.hx @@ -3,7 +3,6 @@ package checks.whitespace; import checkstyle.checks.whitespace.EmptyLinesCheck; class EmptyLinesCheckTest extends CheckTestCase { - static inline var MSG_TOO_MANY:String = "Too many consecutive empty lines (> 1)"; static inline var MSG_AFTER_COMMENT:String = "Empty line not allowed after comment(s)"; @@ -89,7 +88,6 @@ abstract EmptyLinesCheckTests(String) to String { }"; - var TEST2 = " class Test { @@ -123,7 +121,6 @@ abstract EmptyLinesCheckTests(String) to String { } }"; - var TEST3 = " class Test { @@ -134,7 +131,6 @@ abstract EmptyLinesCheckTests(String) to String { } }"; - var TEST4 = " class Test { @@ -144,7 +140,6 @@ abstract EmptyLinesCheckTests(String) to String { var b:Int; } }"; - var TEST5 = " class Test { @@ -152,7 +147,6 @@ abstract EmptyLinesCheckTests(String) to String { var a:Int; }"; - var TEST6 = " class Test { @@ -162,7 +156,6 @@ abstract EmptyLinesCheckTests(String) to String { var a:Int; }"; - var TEST7 = " class Test { @@ -174,27 +167,23 @@ abstract EmptyLinesCheckTests(String) to String { var b:Int; } }"; - var TEST8 = " package pack; using StringTools; class Test {}"; - var TEST9 = " package pack; using StringTools; class Test {}"; - var TEST10 = " class Test { public function new() { var b:Int; } }"; - var TEST11 = " class Test { @@ -202,7 +191,6 @@ abstract EmptyLinesCheckTests(String) to String { var b:Int; } }"; - var TEST12 = " class Test { @@ -211,38 +199,32 @@ abstract EmptyLinesCheckTests(String) to String { var b:Int; } }"; - var TEST13 = " interface Test { var b:Int; }"; - var TEST14 = " interface Test { function test():Void; }"; - var TEST15 = " interface Test { function test():Void; }"; - var TEST16 = " abstract Test(Int) { var A = 10; }"; - var TEST17 = " abstract Test(Int) { var A = 10; }"; - var TEST18 = " abstract Test(Int) { diff --git a/test/checks/whitespace/ExtendedEmptyLinesCheckTest.hx b/test/checks/whitespace/ExtendedEmptyLinesCheckTest.hx index c4cbd855..bd5a0b1d 100644 --- a/test/checks/whitespace/ExtendedEmptyLinesCheckTest.hx +++ b/test/checks/whitespace/ExtendedEmptyLinesCheckTest.hx @@ -1,12 +1,10 @@ package checks.whitespace; import haxe.PosInfos; - import checkstyle.checks.whitespace.ExtendedEmptyLinesCheck; import checkstyle.checks.whitespace.ExtendedEmptyLinesCheck.EmptyLinesPlace; class ExtendedEmptyLinesCheckTest extends CheckTestCase { - static inline var MSG_NONE:String = "should not have empty line(s)"; static inline var MSG_EXACT_1:String = "should have exactly 1 empty line"; static inline var MSG_EXACT_2:String = "should have exactly 2 empty lines"; @@ -17,177 +15,187 @@ class ExtendedEmptyLinesCheckTest extends CheckTestCase 0); @@ -44,28 +42,28 @@ class ConfigParserTest { @Test public function testValidateParserThread() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); - configParser.parseAndValidateConfig({ numberOfCheckerThreads : 0 }, ""); + configParser.parseAndValidateConfig({numberOfCheckerThreads: 0}, ""); Assert.areEqual(5, configParser.numberOfCheckerThreads); - configParser.parseAndValidateConfig({ numberOfCheckerThreads : 10 }, ""); + configParser.parseAndValidateConfig({numberOfCheckerThreads: 10}, ""); Assert.areEqual(10, configParser.numberOfCheckerThreads); - configParser.parseAndValidateConfig({ numberOfCheckerThreads : 50 }, ""); + configParser.parseAndValidateConfig({numberOfCheckerThreads: 50}, ""); Assert.areEqual(15, configParser.numberOfCheckerThreads); configParser.overrideCheckerThreads = 13; - configParser.parseAndValidateConfig({ numberOfCheckerThreads : 14 }, ""); + configParser.parseAndValidateConfig({numberOfCheckerThreads: 14}, ""); Assert.areEqual(13, configParser.numberOfCheckerThreads); configParser.overrideCheckerThreads = 18; - configParser.parseAndValidateConfig({ numberOfCheckerThreads : 14 }, ""); + configParser.parseAndValidateConfig({numberOfCheckerThreads: 14}, ""); Assert.areEqual(15, configParser.numberOfCheckerThreads); } @Test public function testCheckCount() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); @@ -74,7 +72,7 @@ class ConfigParserTest { @Test public function testUnusedChecks() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); @@ -85,7 +83,7 @@ class ConfigParserTest { @Test public function testConfig() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); @@ -93,7 +91,7 @@ class ConfigParserTest { var config:Config = ConfigUtils.makeConfigFromChecker(configParser.checker); config.numberOfCheckerThreads = 11; - configParser = new ConfigParser(function (message:String) { + configParser = new ConfigParser(function(message:String) { Assert.fail(message); }); configParser.parseAndValidateConfig(config, ""); @@ -103,18 +101,16 @@ class ConfigParserTest { @Test public function testConfigVersion1() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseAndValidateConfig( - { - version: 1 - }, - LOCAL_PATH); + configParser.parseAndValidateConfig({ + version: 1 + }, LOCAL_PATH); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); @@ -123,18 +119,16 @@ class ConfigParserTest { @Test public function testConfigWrongVersion() { var failMessage:String = ""; - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { failMessage = message; }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseAndValidateConfig( - { - version: 0 - }, - LOCAL_PATH); + configParser.parseAndValidateConfig({ + version: 0 + }, LOCAL_PATH); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); @@ -143,33 +137,31 @@ class ConfigParserTest { @Test public function testExcludeConfigVersion1() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseExcludes( - { - version: 1 - }); + configParser.parseExcludes({ + version: 1 + }); } @Test public function testExcludeConfigWrongVersion() { var failMessage:String = ""; - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { failMessage = message; }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseExcludes( - { - version: 0 - }); + configParser.parseExcludes({ + version: 0 + }); Assert.areEqual("exclude configuration file has unknown version: 0", failMessage); } @@ -177,7 +169,7 @@ class ConfigParserTest { @Test public function testValidateMode() { var failMessage:String = ""; - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { failMessage = message; }); configParser.validateMode = RELAXED; @@ -187,15 +179,17 @@ class ConfigParserTest { var config:Config = { version: 0, - checks: [{ - "type": "non existing check name" - }, - { - "type": "Trace", - "props": { - "non_existing_property": 100 + checks: [ + { + "type": "non existing check name" + }, + { + "type": "Trace", + "props": { + "non_existing_property": 100 + } } - }] + ] }; configParser.parseAndValidateConfig(config, LOCAL_PATH); diff --git a/test/config/ExcludeManagerTest.hx b/test/config/ExcludeManagerTest.hx index 934abc07..0f7c7181 100644 --- a/test/config/ExcludeManagerTest.hx +++ b/test/config/ExcludeManagerTest.hx @@ -2,11 +2,9 @@ package config; import checkstyle.checks.type.DynamicCheck; import checkstyle.checks.type.ReturnCheck; - import checkstyle.config.ConfigParser; import checkstyle.config.ExcludeManager; import checkstyle.config.ExcludePath; - import checks.CheckTestCase; class ExcludeManagerTest extends CheckTestCase { @@ -24,21 +22,18 @@ class ExcludeManagerTest extends CheckTestCase { @Test public function testExcludeAllConfig() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseExcludes( - { - version: 1, - path: ExcludePath.RELATIVE_TO_PROJECT, - all: [ - "checkstyle.checks.Check$" - ] - }); + configParser.parseExcludes({ + version: 1, + path: ExcludePath.RELATIVE_TO_PROJECT, + all: ["checkstyle.checks.Check$"] + }); Assert.isTrue(ExcludeManager.isExcludedFromAll(CHECK_FILE_NAME)); Assert.isFalse(ExcludeManager.isExcludedFromAll(CHECKER_FILE_NAME)); @@ -47,7 +42,7 @@ class ExcludeManagerTest extends CheckTestCase { @Test public function testExcludeAllConfig2() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); @@ -56,14 +51,11 @@ class ExcludeManagerTest extends CheckTestCase { configParser.paths = ["src", "test"]; - configParser.parseExcludes( - { - version: 1, - path: ExcludePath.RELATIVE_TO_SOURCE, - all: [ - "checkstyle/checks/Check$" - ] - }); + configParser.parseExcludes({ + version: 1, + path: ExcludePath.RELATIVE_TO_SOURCE, + all: ["checkstyle/checks/Check$"] + }); Assert.isTrue(ExcludeManager.isExcludedFromAll(CHECK_FILE_NAME)); Assert.isFalse(ExcludeManager.isExcludedFromAll(CHECKER_FILE_NAME)); @@ -72,22 +64,18 @@ class ExcludeManagerTest extends CheckTestCase { @Test public function testExcludeConfigDynamic() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseExcludes(cast - { - version: 1, - path: ExcludePath.RELATIVE_TO_PROJECT, - Dynamic: [ - "src/checkstyle/checks/Check$", - "test/checkstyle/checks/Check$" - ] - }); + configParser.parseExcludes(cast { + version: 1, + path: ExcludePath.RELATIVE_TO_PROJECT, + Dynamic: ["src/checkstyle/checks/Check$", "test/checkstyle/checks/Check$"] + }); Assert.isTrue(ExcludeManager.isExcludedFromCheck(CHECK_FILE_NAME, DYNAMIC)); Assert.isFalse(ExcludeManager.isExcludedFromCheck(CHECKER_FILE_NAME, DYNAMIC)); @@ -99,48 +87,46 @@ class ExcludeManagerTest extends CheckTestCase { @Test public function testExcludeConfigDynamicRange() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseExcludes(cast - { - version: 1, - path: ExcludePath.RELATIVE_TO_PROJECT, - Dynamic: [ - "src/checkstyle/checks/ChecksInfo$:10", - "src/checkstyle/checks/ChecksInfo$:14-16", - "src/checkstyle/checks/ChecksInfo$:usesDynamic", - "src/checkstyle/checks/ChecksInfo$:DynamicUsingType" - ] - }); + configParser.parseExcludes(cast { + version: 1, + path: ExcludePath.RELATIVE_TO_PROJECT, + Dynamic: [ + "src/checkstyle/checks/ChecksInfo$:10", + "src/checkstyle/checks/ChecksInfo$:14-16", + "src/checkstyle/checks/ChecksInfo$:usesDynamic", + "src/checkstyle/checks/ChecksInfo$:DynamicUsingType" + ] + }); assertNoMsg(new DynamicCheck(), CHECKSINFO, CHECKSINFO_FILE_NAME); } @Test public function testExcludeConfigAllRange() { - var configParser:ConfigParser = new ConfigParser(function (message:String) { + var configParser:ConfigParser = new ConfigParser(function(message:String) { Assert.fail(message); }); Assert.isNotNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - configParser.parseExcludes(cast - { - version: 1, - path: ExcludePath.RELATIVE_TO_PROJECT, - all: [ - "src/checkstyle/checks/ChecksInfo$:10", - "src/checkstyle/checks/ChecksInfo$:14-16", - "src/checkstyle/checks/ChecksInfo$:usesDynamic", - "src/checkstyle/checks/ChecksInfo$:DynamicUsingType" - ] - }); + configParser.parseExcludes(cast { + version: 1, + path: ExcludePath.RELATIVE_TO_PROJECT, + all: [ + "src/checkstyle/checks/ChecksInfo$:10", + "src/checkstyle/checks/ChecksInfo$:14-16", + "src/checkstyle/checks/ChecksInfo$:usesDynamic", + "src/checkstyle/checks/ChecksInfo$:DynamicUsingType" + ] + }); assertNoMsg(new DynamicCheck(), CHECKSINFO, CHECKSINFO_FILE_NAME); assertNoMsg(new ReturnCheck(), CHECKSINFO, CHECKSINFO_FILE_NAME); diff --git a/test/detect/DetectCodingStyleTest.hx b/test/detect/DetectCodingStyleTest.hx index 394b1a5e..84961209 100644 --- a/test/detect/DetectCodingStyleTest.hx +++ b/test/detect/DetectCodingStyleTest.hx @@ -1,7 +1,6 @@ package detect; import byte.ByteData; - import checkstyle.config.CheckConfig; import checkstyle.CheckFile; import checkstyle.SeverityLevel; @@ -59,7 +58,6 @@ import checkstyle.checks.whitespace.WrapCheckBase.WrapCheckBaseOption; import checkstyle.detect.DetectCodingStyle; class DetectCodingStyleTest { - // checkstyle.checks.block @Test public function testDetectConditionalCompilation() { @@ -531,7 +529,7 @@ class DetectCodingStyleTest { } function buildCheckFile(src:String):CheckFile { - return {name:"Test.hx", content:ByteData.ofString(src), index:0}; + return {name: "Test.hx", content: ByteData.ofString(src), index: 0}; } } diff --git a/test/import.hx b/test/import.hx index 1c934e38..13b351df 100644 --- a/test/import.hx +++ b/test/import.hx @@ -1,3 +1,2 @@ import haxe.PosInfos; - import massive.munit.Assert; \ No newline at end of file diff --git a/test/misc/CheckerTest.hx b/test/misc/CheckerTest.hx index fc9ed0d6..adac7fb6 100644 --- a/test/misc/CheckerTest.hx +++ b/test/misc/CheckerTest.hx @@ -3,7 +3,6 @@ package misc; import checkstyle.Checker; class CheckerTest { - @Test public function testEmptyLinesIdx() { var checker:Checker = new Checker(); diff --git a/test/misc/ExtensionsTest.hx b/test/misc/ExtensionsTest.hx index fd8266e4..d4961eff 100644 --- a/test/misc/ExtensionsTest.hx +++ b/test/misc/ExtensionsTest.hx @@ -4,7 +4,6 @@ import checks.CheckTestCase; import checkstyle.checks.whitespace.IndentationCharacterCheck; class ExtensionsTest extends CheckTestCase { - @Test public function testExtensions() { assertNoMsg(new IndentationCharacterCheck(), TEST1); diff --git a/test/misc/ThreadTest.hx b/test/misc/ThreadTest.hx index 112a3fdb..382222ce 100644 --- a/test/misc/ThreadTest.hx +++ b/test/misc/ThreadTest.hx @@ -1,7 +1,6 @@ package misc; import byte.ByteData; - import checkstyle.CheckFile; import checkstyle.reporter.ReporterManager; import checkstyle.Checker; @@ -9,11 +8,9 @@ import checkstyle.ParserQueue; import checkstyle.CheckerPool; import checkstyle.checks.whitespace.IndentationCheck; import checks.whitespace.IndentationCheckTest.IndentationCheckTests; - import checks.CheckTestCase.TestReporter; class ThreadTest { - static inline var FILE_NAME:String = "Test.hx"; var checker:Checker; @@ -32,7 +29,7 @@ class ThreadTest { var files:Array = setupFiles(13); var parseQueue = new ParserQueue(files, checker); - parseQueue.start (1); + parseQueue.start(1); Assert.isFalse(parseQueue.isFinished()); Sys.sleep(1); @@ -60,10 +57,10 @@ class ThreadTest { var files:Array = setupFiles(13); var parseQueue = new ParserQueue(files, checker); - parseQueue.start (1); + parseQueue.start(1); var checkerPool = new CheckerPool(parseQueue, checker); - checkerPool.start (5); + checkerPool.start(5); Assert.isFalse(parseQueue.isFinished()); Assert.isFalse(checkerPool.isFinished());