Add basic groovy code style validation.
IDK how well this would work on a gradle script but might be interesting to try on yarn or something.
This commit is contained in:
		
							parent
							
								
									759cac2e6b
								
							
						
					
					
						commit
						ff6701e817
					
				
					 5 changed files with 76 additions and 3 deletions
				
			
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							|  | @ -19,4 +19,5 @@ | ||||||
| !/README.md | !/README.md | ||||||
| !/settings.gradle | !/settings.gradle | ||||||
| !/Jenkinsfile | !/Jenkinsfile | ||||||
| !/checkstyle.xml | !/checkstyle.xml | ||||||
|  | !/codenarc.groovy | ||||||
|  | @ -7,6 +7,7 @@ plugins { | ||||||
| 	id 'groovy' | 	id 'groovy' | ||||||
| 	id 'checkstyle' | 	id 'checkstyle' | ||||||
| 	id 'jacoco' | 	id 'jacoco' | ||||||
|  | 	id 'codenarc' | ||||||
| 	id "org.cadixdev.licenser" version "0.5.0" | 	id "org.cadixdev.licenser" version "0.5.0" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -110,6 +111,11 @@ checkstyle { | ||||||
| 	toolVersion = '8.39' | 	toolVersion = '8.39' | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | codenarc { | ||||||
|  | 	toolVersion = "2.0.0" | ||||||
|  | 	configFile = file("codenarc.groovy") | ||||||
|  | } | ||||||
|  | 
 | ||||||
| gradlePlugin { | gradlePlugin { | ||||||
| 	plugins { | 	plugins { | ||||||
| 		fabricLoom { | 		fabricLoom { | ||||||
|  |  | ||||||
							
								
								
									
										66
									
								
								codenarc.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								codenarc.groovy
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,66 @@ | ||||||
|  | ruleset { | ||||||
|  |     UnnecessarySemicolon | ||||||
|  |     BlockEndsWithBlankLine | ||||||
|  |     BlockStartsWithBlankLine | ||||||
|  |     ConsecutiveBlankLines | ||||||
|  |     MissingBlankLineAfterImports | ||||||
|  |     MissingBlankLineAfterPackage | ||||||
|  | 
 | ||||||
|  |     // Braces | ||||||
|  |     BracesForClass | ||||||
|  |     BracesForForLoop | ||||||
|  |     BracesForIfElse | ||||||
|  |     BracesForMethod | ||||||
|  |     BracesForTryCatchFinally | ||||||
|  | 
 | ||||||
|  |     // Spaces | ||||||
|  |     SpaceAfterCatch | ||||||
|  |     SpaceAfterComma | ||||||
|  |     SpaceAfterClosingBrace | ||||||
|  |     SpaceAfterFor | ||||||
|  |     SpaceAfterIf | ||||||
|  |     SpaceAfterOpeningBrace | ||||||
|  |     SpaceAfterSemicolon | ||||||
|  |     SpaceAfterSwitch | ||||||
|  |     SpaceAfterWhile | ||||||
|  |     SpaceAroundClosureArrow | ||||||
|  |     SpaceAroundMapEntryColon | ||||||
|  |     SpaceAroundOperator | ||||||
|  |     SpaceBeforeClosingBrace | ||||||
|  |     SpaceBeforeOpeningBrace | ||||||
|  |     TrailingWhitespace | ||||||
|  | 
 | ||||||
|  |     // Groovyism - See: https://codenarc.org/codenarc-rules-groovyism.html | ||||||
|  |     ClosureAsLastMethodParameter | ||||||
|  |     ExplicitArrayListInstantiation | ||||||
|  |     ExplicitCallToAndMethod | ||||||
|  |     ExplicitCallToCompareToMethod | ||||||
|  |     ExplicitCallToDivMethod | ||||||
|  |     ExplicitCallToEqualsMethod | ||||||
|  |     ExplicitCallToGetAtMethod | ||||||
|  |     ExplicitCallToLeftShiftMethod | ||||||
|  |     ExplicitCallToMinusMethod | ||||||
|  |     ExplicitCallToMultiplyMethod | ||||||
|  |     ExplicitCallToModMethod | ||||||
|  |     ExplicitCallToOrMethod | ||||||
|  |     ExplicitCallToPlusMethod | ||||||
|  |     ExplicitCallToPowerMethod | ||||||
|  |     ExplicitCallToRightShiftMethod | ||||||
|  |     ExplicitCallToXorMethod | ||||||
|  |     ExplicitHashMapInstantiation | ||||||
|  |     ExplicitLinkedHashMapInstantiation | ||||||
|  |     ExplicitHashSetInstantiation | ||||||
|  |     ExplicitLinkedListInstantiation | ||||||
|  |     ExplicitStackInstantiation | ||||||
|  |     ExplicitTreeSetInstantiation | ||||||
|  |     GetterMethodCouldBeProperty | ||||||
|  |     GStringAsMapKey | ||||||
|  |     GStringExpressionWithinString | ||||||
|  |     CouldBeElvis | ||||||
|  |     TernaryCouldBeElvis | ||||||
|  |     FieldTypeRequired | ||||||
|  |     MethodParameterTypeRequired | ||||||
|  | 
 | ||||||
|  |     //Misc | ||||||
|  |     LongLiteralWithLowerCaseL | ||||||
|  | } | ||||||
|  | @ -43,7 +43,7 @@ class AccessWidenerTest extends Specification implements ProjectTestTrait, Archi | ||||||
| 			def result = create("build", gradle) | 			def result = create("build", gradle) | ||||||
| 		then: | 		then: | ||||||
| 			result.task(":build").outcome == SUCCESS | 			result.task(":build").outcome == SUCCESS | ||||||
| 			getArchiveEntry("fabric-example-mod-1.0.0.jar", "modid.accesswidener") == expected().replaceAll('\r','') | 			getArchiveEntry("fabric-example-mod-1.0.0.jar", "modid.accesswidener") == expected().replaceAll('\r', '') | ||||||
| 		where: | 		where: | ||||||
| 			gradle     | _ | 			gradle     | _ | ||||||
| 			'6.8.3'    | _ | 			'6.8.3'    | _ | ||||||
|  |  | ||||||
|  | @ -43,7 +43,7 @@ trait ProjectTestTrait { | ||||||
| 			throw new FileNotFoundException("Failed to find project directory at:" + baseProjectDir.absolutePath) | 			throw new FileNotFoundException("Failed to find project directory at:" + baseProjectDir.absolutePath) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		baseProjectDir.eachFileRecurse {file -> | 		baseProjectDir.eachFileRecurse { file -> | ||||||
| 			if (file.isDirectory()) { | 			if (file.isDirectory()) { | ||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue