codenarc.groovy 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. ruleset {
  2. // rulesets/basic.xml
  3. /*
  4. AssertWithinFinallyBlock
  5. AssignmentInConditional
  6. BigDecimalInstantiation
  7. BitwiseOperatorInConditional
  8. BooleanGetBoolean
  9. BrokenNullCheck
  10. BrokenOddnessCheck
  11. ClassForName
  12. ComparisonOfTwoConstants
  13. ComparisonWithSelf
  14. ConstantAssertExpression
  15. ConstantIfExpression
  16. ConstantTernaryExpression
  17. DeadCode
  18. DoubleNegative
  19. DuplicateCaseStatement
  20. DuplicateMapKey
  21. DuplicateSetValue
  22. EmptyCatchBlock
  23. EmptyClass
  24. EmptyElseBlock
  25. EmptyFinallyBlock
  26. EmptyForStatement
  27. EmptyIfStatement
  28. EmptyInstanceInitializer
  29. EmptyMethod
  30. EmptyStaticInitializer
  31. EmptySwitchStatement
  32. EmptySynchronizedStatement
  33. EmptyTryBlock
  34. EmptyWhileStatement
  35. EqualsAndHashCode
  36. EqualsOverloaded
  37. ExplicitGarbageCollection
  38. ForLoopShouldBeWhileLoop
  39. HardCodedWindowsFileSeparator
  40. HardCodedWindowsRootDirectory
  41. IntegerGetInteger
  42. RandomDoubleCoercedToZero
  43. RemoveAllOnSelf
  44. ReturnFromFinallyBlock
  45. ThrowExceptionFromFinallyBlock
  46. */
  47. // rulesets/braces.xml
  48. ElseBlockBraces
  49. ForStatementBraces
  50. IfStatementBraces
  51. WhileStatementBraces
  52. // rulesets/concurrency.xml
  53. /*
  54. BusyWait
  55. DoubleCheckedLocking
  56. InconsistentPropertyLocking
  57. InconsistentPropertySynchronization
  58. NestedSynchronization
  59. StaticCalendarField
  60. StaticConnection
  61. StaticDateFormatField
  62. StaticMatcherField
  63. StaticSimpleDateFormatField
  64. SynchronizedMethod
  65. SynchronizedOnBoxedPrimitive
  66. SynchronizedOnGetClass
  67. SynchronizedOnReentrantLock
  68. SynchronizedOnString
  69. SynchronizedOnThis
  70. SynchronizedReadObjectMethod
  71. SystemRunFinalizersOnExit
  72. ThisReferenceEscapesConstructor
  73. ThreadGroup
  74. ThreadLocalNotStaticFinal
  75. ThreadYield
  76. UseOfNotifyMethod
  77. VolatileArrayField
  78. VolatileLongOrDoubleField
  79. WaitOutsideOfWhileLoop
  80. */
  81. // rulesets/convention.xml
  82. /*
  83. ConfusingTernary
  84. CouldBeElvis
  85. HashtableIsObsolete
  86. IfStatementCouldBeTernary
  87. InvertedIfElse
  88. LongLiteralWithLowerCaseL
  89. ParameterReassignment
  90. TernaryCouldBeElvis
  91. VectorIsObsolete
  92. */
  93. // rulesets/design.xml
  94. /*
  95. AbstractClassWithPublicConstructor
  96. AbstractClassWithoutAbstractMethod
  97. BooleanMethodReturnsNull
  98. BuilderMethodWithSideEffects
  99. CloneableWithoutClone
  100. CloseWithoutCloseable
  101. CompareToWithoutComparable
  102. ConstantsOnlyInterface
  103. EmptyMethodInAbstractClass
  104. FinalClassWithProtectedMember
  105. ImplementationAsType
  106. LocaleSetDefault
  107. PrivateFieldCouldBeFinal
  108. PublicInstanceField
  109. ReturnsNullInsteadOfEmptyArray
  110. ReturnsNullInsteadOfEmptyCollection
  111. SimpleDateFormatMissingLocale
  112. StatelessSingleton
  113. */
  114. // rulesets/dry.xml
  115. /*
  116. DuplicateListLiteral
  117. DuplicateMapLiteral
  118. DuplicateNumberLiteral
  119. DuplicateStringLiteral
  120. */
  121. // rulesets/enhanced.xml
  122. /*
  123. CloneWithoutCloneable
  124. JUnitAssertEqualsConstantActualValue
  125. UnsafeImplementationAsMap
  126. */
  127. // rulesets/exceptions.xml
  128. /*
  129. CatchArrayIndexOutOfBoundsException
  130. CatchError
  131. CatchException
  132. CatchIllegalMonitorStateException
  133. CatchIndexOutOfBoundsException
  134. CatchNullPointerException
  135. CatchRuntimeException
  136. CatchThrowable
  137. ConfusingClassNamedException
  138. ExceptionExtendsError
  139. ExceptionNotThrown
  140. MissingNewInThrowStatement
  141. ReturnNullFromCatchBlock
  142. SwallowThreadDeath
  143. ThrowError
  144. ThrowException
  145. ThrowNullPointerException
  146. ThrowRuntimeException
  147. ThrowThrowable
  148. */
  149. // rulesets/formatting.xml
  150. /*
  151. BracesForClass
  152. BracesForForLoop
  153. BracesForIfElse
  154. BracesForMethod
  155. BracesForTryCatchFinally
  156. ClassJavadoc
  157. ClosureStatementOnOpeningLineOfMultipleLineClosure
  158. LineLength
  159. SpaceAfterCatch
  160. SpaceAfterClosingBrace
  161. SpaceAfterComma
  162. SpaceAfterFor
  163. SpaceAfterIf
  164. SpaceAfterOpeningBrace
  165. SpaceAfterSemicolon
  166. SpaceAfterSwitch
  167. SpaceAfterWhile
  168. SpaceAroundClosureArrow
  169. SpaceAroundMapEntryColon
  170. SpaceAroundOperator
  171. SpaceBeforeClosingBrace
  172. SpaceBeforeOpeningBrace
  173. */
  174. // rulesets/generic.xml
  175. /*
  176. IllegalClassMember
  177. IllegalClassReference
  178. IllegalPackageReference
  179. IllegalRegex
  180. IllegalString
  181. RequiredRegex
  182. RequiredString
  183. StatelessClass
  184. */
  185. // rulesets/grails.xml
  186. /*
  187. GrailsDomainHasEquals
  188. GrailsDomainHasToString
  189. GrailsDomainReservedSqlKeywordName
  190. GrailsDomainWithServiceReference
  191. GrailsDuplicateConstraint
  192. GrailsDuplicateMapping
  193. GrailsPublicControllerMethod
  194. GrailsServletContextReference
  195. GrailsSessionReference // DEPRECATED
  196. GrailsStatelessService
  197. */
  198. // rulesets/groovyism.xml
  199. /*
  200. AssignCollectionSort
  201. AssignCollectionUnique
  202. ClosureAsLastMethodParameter
  203. CollectAllIsDeprecated
  204. ConfusingMultipleReturns
  205. ExplicitArrayListInstantiation
  206. ExplicitCallToAndMethod
  207. ExplicitCallToCompareToMethod
  208. ExplicitCallToDivMethod
  209. ExplicitCallToEqualsMethod
  210. ExplicitCallToGetAtMethod
  211. ExplicitCallToLeftShiftMethod
  212. ExplicitCallToMinusMethod
  213. ExplicitCallToModMethod
  214. ExplicitCallToMultiplyMethod
  215. ExplicitCallToOrMethod
  216. ExplicitCallToPlusMethod
  217. ExplicitCallToPowerMethod
  218. ExplicitCallToRightShiftMethod
  219. ExplicitCallToXorMethod
  220. ExplicitHashMapInstantiation
  221. ExplicitHashSetInstantiation
  222. ExplicitLinkedHashMapInstantiation
  223. ExplicitLinkedListInstantiation
  224. ExplicitStackInstantiation
  225. ExplicitTreeSetInstantiation
  226. GStringAsMapKey
  227. GStringExpressionWithinString
  228. GetterMethodCouldBeProperty
  229. GroovyLangImmutable
  230. UseCollectMany
  231. UseCollectNested
  232. */
  233. // rulesets/imports.xml
  234. DuplicateImport
  235. ImportFromSamePackage
  236. // ImportFromSunPackages
  237. // MisorderedStaticImports
  238. UnnecessaryGroovyImport
  239. UnusedImport
  240. // rulesets/jdbc.xml
  241. /*
  242. DirectConnectionManagement
  243. JdbcConnectionReference
  244. JdbcResultSetReference
  245. JdbcStatementReference
  246. */
  247. // rulesets/junit.xml
  248. /*
  249. ChainedTest
  250. CoupledTestCase
  251. JUnitAssertAlwaysFails
  252. JUnitAssertAlwaysSucceeds
  253. JUnitFailWithoutMessage
  254. JUnitLostTest
  255. JUnitPublicField
  256. JUnitPublicNonTestMethod
  257. JUnitSetUpCallsSuper
  258. JUnitStyleAssertions
  259. JUnitTearDownCallsSuper
  260. JUnitTestMethodWithoutAssert
  261. JUnitUnnecessarySetUp
  262. JUnitUnnecessaryTearDown
  263. JUnitUnnecessaryThrowsException
  264. SpockIgnoreRestUsed
  265. UnnecessaryFail
  266. UseAssertEqualsInsteadOfAssertTrue
  267. UseAssertFalseInsteadOfNegation
  268. UseAssertNullInsteadOfAssertEquals
  269. UseAssertSameInsteadOfAssertTrue
  270. UseAssertTrueInsteadOfAssertEquals
  271. UseAssertTrueInsteadOfNegation
  272. */
  273. // rulesets/logging.xml
  274. /*
  275. LoggerForDifferentClass
  276. LoggerWithWrongModifiers
  277. LoggingSwallowsStacktrace
  278. MultipleLoggers
  279. PrintStackTrace
  280. Println
  281. SystemErrPrint
  282. SystemOutPrint
  283. */
  284. // rulesets/naming.xml
  285. AbstractClassName
  286. ClassName {
  287. regex = '^[A-Z][\\$a-zA-Z0-9]*$'
  288. }
  289. ClassNameSameAsFilename
  290. // ConfusingMethodName
  291. // FactoryMethodName
  292. FieldName {
  293. regex = '^_?[a-z][a-zA-Z0-9]*$'
  294. finalRegex = '^_?[a-z][a-zA-Z0-9]*$'
  295. // can be either constant (ABC_XYZ) or non-constant (abcXyz)
  296. staticFinalRegex = '^[A-Z][A-Z_0-9]*$|^_?[a-z][a-zA-Z0-9]*$'
  297. }
  298. InterfaceName
  299. MethodName {
  300. regex = '^[a-z][\\$_a-zA-Z0-9]*$|^.*\\s.*$'
  301. }
  302. ObjectOverrideMisspelledMethodName
  303. ParameterName
  304. PropertyName
  305. VariableName {
  306. finalRegex = '^[a-z][a-zA-Z0-9]*$'
  307. }
  308. // rulesets/security.xml
  309. /*
  310. FileCreateTempFile
  311. InsecureRandom
  312. JavaIoPackageAccess
  313. NonFinalPublicField
  314. NonFinalSubclassOfSensitiveInterface
  315. ObjectFinalize
  316. PublicFinalizeMethod
  317. SystemExit
  318. UnsafeArrayDeclaration
  319. */
  320. // rulesets/serialization.xml
  321. /*
  322. EnumCustomSerializationIgnored
  323. SerialPersistentFields
  324. SerialVersionUID
  325. SerializableClassMustDefineSerialVersionUID
  326. */
  327. // rulesets/size.xml
  328. /*
  329. AbcComplexity // DEPRECATED: Use the AbcMetric rule instead. Requires the GMetrics jar
  330. AbcMetric // Requires the GMetrics jar
  331. ClassSize
  332. CrapMetric // Requires the GMetrics jar and a Cobertura coverage file
  333. CyclomaticComplexity // Requires the GMetrics jar
  334. MethodCount
  335. MethodSize
  336. NestedBlockDepth
  337. */
  338. // rulesets/unnecessary.xml
  339. AddEmptyString
  340. ConsecutiveLiteralAppends
  341. ConsecutiveStringConcatenation
  342. UnnecessaryBigDecimalInstantiation
  343. UnnecessaryBigIntegerInstantiation
  344. UnnecessaryBooleanExpression
  345. UnnecessaryBooleanInstantiation
  346. // UnnecessaryCallForLastElement
  347. UnnecessaryCallToSubstring
  348. UnnecessaryCatchBlock
  349. // UnnecessaryCollectCall
  350. UnnecessaryCollectionCall
  351. UnnecessaryConstructor
  352. UnnecessaryDefInFieldDeclaration
  353. UnnecessaryDefInMethodDeclaration
  354. UnnecessaryDefInVariableDeclaration
  355. UnnecessaryDotClass
  356. UnnecessaryDoubleInstantiation
  357. UnnecessaryElseStatement
  358. UnnecessaryFinalOnPrivateMethod
  359. UnnecessaryFloatInstantiation
  360. // UnnecessaryGString
  361. // UnnecessaryGetter
  362. UnnecessaryIfStatement
  363. UnnecessaryInstanceOfCheck
  364. UnnecessaryInstantiationToGetClass
  365. UnnecessaryIntegerInstantiation
  366. UnnecessaryLongInstantiation
  367. UnnecessaryModOne
  368. UnnecessaryNullCheck
  369. UnnecessaryNullCheckBeforeInstanceOf
  370. // UnnecessaryObjectReferences
  371. UnnecessaryOverridingMethod
  372. // UnnecessaryPackageReference
  373. UnnecessaryParenthesesForMethodCallWithClosure
  374. UnnecessaryPublicModifier
  375. // UnnecessaryReturnKeyword
  376. // UnnecessarySelfAssignment
  377. UnnecessarySemicolon
  378. UnnecessaryStringInstantiation
  379. // UnnecessarySubstring
  380. UnnecessaryTernaryExpression
  381. UnnecessaryTransientModifier
  382. // rulesets/unused.xml
  383. UnusedArray
  384. // UnusedMethodParameter
  385. UnusedObject
  386. UnusedPrivateField
  387. UnusedPrivateMethod
  388. UnusedPrivateMethodParameter
  389. UnusedVariable
  390. }