npm-groovy-lint
Advanced tools
Comparing version 3.0.1-beta.4 to 3.0.1
# Changelog | ||
## [3.0.1] 2020-03-17 | ||
### Added | ||
- Add new test suites: errors.test.js and miscellaneous.test.js | ||
### Changed | ||
- Use JSON as default GroovyLint configuration file type | ||
- Order of fixable rules must be defined in groovy-lint-rules.js | ||
- Do not load rules test data except during tests | ||
- Do not lint again after a call to fixErrors on an existing NpmGroovyLint instance (except if lintAgainAfterFix : true is sent in options) | ||
- Fix: Deletion of temp RuleSite file | ||
- Fix: UnnecessarySemiColon rule | ||
- Fix: ClosingBraceNotAlone rule | ||
## [3.0.0] 2020-03-15 | ||
@@ -14,3 +30,3 @@ | ||
## Changes | ||
## Changed | ||
@@ -17,0 +33,0 @@ - Split rules definition into files instead of all in a huge single file |
{ | ||
"extends": "all", | ||
"rules": { | ||
"basic.AssertWithinFinallyBlock": {}, | ||
"basic.AssignmentInConditional": {}, | ||
"basic.BigDecimalInstantiation": {}, | ||
"basic.BitwiseOperatorInConditional": {}, | ||
"basic.BooleanGetBoolean": {}, | ||
"basic.BrokenNullCheck": {}, | ||
"basic.BrokenOddnessCheck": {}, | ||
"basic.ClassForName": {}, | ||
"basic.ComparisonOfTwoConstants": {}, | ||
"basic.ComparisonWithSelf": {}, | ||
"basic.ConstantAssertExpression": {}, | ||
"basic.ConstantIfExpression": {}, | ||
"basic.ConstantTernaryExpression": {}, | ||
"basic.DeadCode": {}, | ||
"basic.DoubleNegative": {}, | ||
"basic.DuplicateCaseStatement": {}, | ||
"basic.DuplicateMapKey": {}, | ||
"basic.DuplicateSetValue": {}, | ||
"basic.EmptyCatchBlock": {}, | ||
"basic.EmptyClass": {}, | ||
"basic.EmptyElseBlock": {}, | ||
"basic.EmptyFinallyBlock": {}, | ||
"basic.EmptyForStatement": {}, | ||
"basic.EmptyIfStatement": {}, | ||
"basic.EmptyInstanceInitializer": {}, | ||
"basic.EmptyMethod": {}, | ||
"basic.EmptyStaticInitializer": {}, | ||
"basic.EmptySwitchStatement": {}, | ||
"basic.EmptySynchronizedStatement": {}, | ||
"basic.EmptyTryBlock": {}, | ||
"basic.EmptyWhileStatement": {}, | ||
"basic.EqualsAndHashCode": {}, | ||
"basic.EqualsOverloaded": {}, | ||
"basic.ExplicitGarbageCollection": {}, | ||
"basic.ForLoopShouldBeWhileLoop": {}, | ||
"basic.HardCodedWindowsFileSeparator": {}, | ||
"basic.HardCodedWindowsRootDirectory": {}, | ||
"basic.IntegerGetInteger": {}, | ||
"basic.MultipleUnaryOperators": {}, | ||
"basic.RandomDoubleCoercedToZero": {}, | ||
"basic.RemoveAllOnSelf": {}, | ||
"basic.ReturnFromFinallyBlock": {}, | ||
"basic.ThrowExceptionFromFinallyBlock": {}, | ||
"braces.ElseBlockBraces": {}, | ||
"braces.ForStatementBraces": {}, | ||
"braces.IfStatementBraces": {}, | ||
"braces.WhileStatementBraces": {}, | ||
"comments.ClassJavadoc": {}, | ||
"comments.JavadocConsecutiveEmptyLines": {}, | ||
"comments.JavadocEmptyAuthorTag": {}, | ||
"comments.JavadocEmptyExceptionTag": {}, | ||
"comments.JavadocEmptyFirstLine": {}, | ||
"comments.JavadocEmptyLastLine": {}, | ||
"comments.JavadocEmptyParamTag": {}, | ||
"comments.JavadocEmptyReturnTag": {}, | ||
"comments.JavadocEmptySeeTag": {}, | ||
"comments.JavadocEmptySinceTag": {}, | ||
"comments.JavadocEmptyThrowsTag": {}, | ||
"comments.JavadocEmptyVersionTag": {}, | ||
"comments.JavadocMissingExceptionDescription": {}, | ||
"comments.JavadocMissingParamDescription": {}, | ||
"comments.JavadocMissingThrowsDescription": {}, | ||
"concurrency.BusyWait": {}, | ||
"concurrency.DoubleCheckedLocking": {}, | ||
"concurrency.InconsistentPropertyLocking": {}, | ||
"concurrency.InconsistentPropertySynchronization": {}, | ||
"concurrency.NestedSynchronization": {}, | ||
"concurrency.StaticCalendarField": {}, | ||
"concurrency.StaticConnection": {}, | ||
"concurrency.StaticDateFormatField": {}, | ||
"concurrency.StaticMatcherField": {}, | ||
"concurrency.StaticSimpleDateFormatField": {}, | ||
"concurrency.SynchronizedMethod": {}, | ||
"concurrency.SynchronizedOnBoxedPrimitive": {}, | ||
"concurrency.SynchronizedOnGetClass": {}, | ||
"concurrency.SynchronizedOnReentrantLock": {}, | ||
"concurrency.SynchronizedOnString": {}, | ||
"concurrency.SynchronizedOnThis": {}, | ||
"concurrency.SynchronizedReadObjectMethod": {}, | ||
"concurrency.SystemRunFinalizersOnExit": {}, | ||
"concurrency.ThisReferenceEscapesConstructor": {}, | ||
"concurrency.ThreadGroup": {}, | ||
"concurrency.ThreadLocalNotStaticFinal": {}, | ||
"concurrency.ThreadYield": {}, | ||
"concurrency.UseOfNotifyMethod": {}, | ||
"concurrency.VolatileArrayField": {}, | ||
"concurrency.VolatileLongOrDoubleField": {}, | ||
"concurrency.WaitOutsideOfWhileLoop": {}, | ||
"convention.CompileStatic": {}, | ||
"convention.ConfusingTernary": {}, | ||
"convention.CouldBeElvis": {}, | ||
"convention.CouldBeSwitchStatement": {}, | ||
"convention.FieldTypeRequired": {}, | ||
"convention.HashtableIsObsolete": {}, | ||
"convention.IfStatementCouldBeTernary": {}, | ||
"convention.InvertedCondition": {}, | ||
"convention.InvertedIfElse": {}, | ||
"convention.LongLiteralWithLowerCaseL": {}, | ||
"convention.MethodParameterTypeRequired": {}, | ||
"convention.MethodReturnTypeRequired": {}, | ||
"convention.NoDef": {}, | ||
"convention.NoJavaUtilDate": {}, | ||
"convention.NoTabCharacter": {}, | ||
"convention.ParameterReassignment": {}, | ||
"convention.PublicMethodsBeforeNonPublicMethods": {}, | ||
"convention.StaticFieldsBeforeInstanceFields": {}, | ||
"convention.StaticMethodsBeforeInstanceMethods": {}, | ||
"convention.TernaryCouldBeElvis": {}, | ||
"convention.TrailingComma": {}, | ||
"convention.VariableTypeRequired": {}, | ||
"convention.VectorIsObsolete": {}, | ||
"design.AbstractClassWithPublicConstructor": {}, | ||
"design.AbstractClassWithoutAbstractMethod": {}, | ||
"design.AssignmentToStaticFieldFromInstanceMethod": {}, | ||
"design.BooleanMethodReturnsNull": {}, | ||
"design.BuilderMethodWithSideEffects": {}, | ||
"design.CloneableWithoutClone": {}, | ||
"design.CloseWithoutCloseable": {}, | ||
"design.CompareToWithoutComparable": {}, | ||
"design.ConstantsOnlyInterface": {}, | ||
"design.EmptyMethodInAbstractClass": {}, | ||
"design.FinalClassWithProtectedMember": {}, | ||
"design.ImplementationAsType": {}, | ||
"design.Instanceof": {}, | ||
"design.LocaleSetDefault": {}, | ||
"design.NestedForLoop": {}, | ||
"design.PrivateFieldCouldBeFinal": {}, | ||
"design.PublicInstanceField": {}, | ||
"design.ReturnsNullInsteadOfEmptyArray": {}, | ||
"design.ReturnsNullInsteadOfEmptyCollection": {}, | ||
"design.SimpleDateFormatMissingLocale": {}, | ||
"design.StatelessSingleton": {}, | ||
"design.ToStringReturnsNull": {}, | ||
"dry.DuplicateListLiteral": {}, | ||
"dry.DuplicateMapLiteral": {}, | ||
"dry.DuplicateNumberLiteral": {}, | ||
"dry.DuplicateStringLiteral": {}, | ||
"enhanced.CloneWithoutCloneable": {}, | ||
"enhanced.JUnitAssertEqualsConstantActualValue": {}, | ||
"enhanced.MissingOverrideAnnotation": {}, | ||
"enhanced.UnsafeImplementationAsMap": {}, | ||
"exceptions.CatchArrayIndexOutOfBoundsException": {}, | ||
"exceptions.CatchError": {}, | ||
"exceptions.CatchException": {}, | ||
"exceptions.CatchIllegalMonitorStateException": {}, | ||
"exceptions.CatchIndexOutOfBoundsException": {}, | ||
"exceptions.CatchNullPointerException": {}, | ||
"exceptions.CatchRuntimeException": {}, | ||
"exceptions.CatchThrowable": {}, | ||
"exceptions.ConfusingClassNamedException": {}, | ||
"exceptions.ExceptionExtendsError": {}, | ||
"exceptions.ExceptionExtendsThrowable": {}, | ||
"exceptions.ExceptionNotThrown": {}, | ||
"exceptions.MissingNewInThrowStatement": {}, | ||
"exceptions.ReturnNullFromCatchBlock": {}, | ||
"exceptions.SwallowThreadDeath": {}, | ||
"exceptions.ThrowError": {}, | ||
"exceptions.ThrowException": {}, | ||
"exceptions.ThrowNullPointerException": {}, | ||
"exceptions.ThrowRuntimeException": {}, | ||
"exceptions.ThrowThrowable": {}, | ||
"formatting.BlankLineBeforePackage": {}, | ||
"formatting.BlockEndsWithBlankLine": {}, | ||
"formatting.BlockStartsWithBlankLine": {}, | ||
"formatting.BracesForClass": {}, | ||
"formatting.BracesForForLoop": {}, | ||
"formatting.BracesForIfElse": {}, | ||
"formatting.BracesForMethod": {}, | ||
"formatting.BracesForTryCatchFinally": {}, | ||
"formatting.ClassEndsWithBlankLine": {}, | ||
"formatting.ClassStartsWithBlankLine": {}, | ||
"formatting.ClosureStatementOnOpeningLineOfMultipleLineClosure": {}, | ||
"formatting.ConsecutiveBlankLines": {}, | ||
"formatting.FileEndsWithoutNewline": {}, | ||
"formatting.Indentation": {}, | ||
"formatting.LineLength": {}, | ||
"formatting.MissingBlankLineAfterImports": {}, | ||
"formatting.MissingBlankLineAfterPackage": {}, | ||
"formatting.SpaceAfterCatch": {}, | ||
"formatting.SpaceAfterClosingBrace": {}, | ||
"formatting.SpaceAfterComma": {}, | ||
"formatting.SpaceAfterFor": {}, | ||
"formatting.SpaceAfterIf": {}, | ||
"formatting.SpaceAfterOpeningBrace": {}, | ||
"formatting.SpaceAfterSemicolon": {}, | ||
"formatting.SpaceAfterSwitch": {}, | ||
"formatting.SpaceAfterWhile": {}, | ||
"formatting.SpaceAroundClosureArrow": {}, | ||
"formatting.SpaceAroundMapEntryColon": {}, | ||
"formatting.SpaceAroundOperator": {}, | ||
"formatting.SpaceBeforeClosingBrace": {}, | ||
"formatting.SpaceBeforeOpeningBrace": {}, | ||
"formatting.TrailingWhitespace": {}, | ||
"generic.IllegalClassMember": {}, | ||
"generic.IllegalClassReference": {}, | ||
"generic.IllegalPackageReference": {}, | ||
"generic.IllegalRegex": {}, | ||
"generic.IllegalString": {}, | ||
"generic.IllegalSubclass": {}, | ||
"generic.RequiredRegex": {}, | ||
"generic.RequiredString": {}, | ||
"generic.StatelessClass": {}, | ||
"grails.GrailsDomainHasEquals": {}, | ||
"grails.GrailsDomainHasToString": {}, | ||
"grails.GrailsDomainReservedSqlKeywordName": {}, | ||
"grails.GrailsDomainStringPropertyMaxSize": {}, | ||
"grails.GrailsDomainWithServiceReference": {}, | ||
"grails.GrailsDuplicateConstraint": {}, | ||
"grails.GrailsDuplicateMapping": {}, | ||
"grails.GrailsMassAssignment": {}, | ||
"grails.GrailsPublicControllerMethod": {}, | ||
"grails.GrailsServletContextReference": {}, | ||
"grails.GrailsStatelessService": {}, | ||
"groovyism.AssignCollectionSort": {}, | ||
"groovyism.AssignCollectionUnique": {}, | ||
"groovyism.ClosureAsLastMethodParameter": {}, | ||
"groovyism.CollectAllIsDeprecated": {}, | ||
"groovyism.ConfusingMultipleReturns": {}, | ||
"groovyism.ExplicitArrayListInstantiation": {}, | ||
"groovyism.ExplicitCallToAndMethod": {}, | ||
"groovyism.ExplicitCallToCompareToMethod": {}, | ||
"groovyism.ExplicitCallToDivMethod": {}, | ||
"groovyism.ExplicitCallToEqualsMethod": {}, | ||
"groovyism.ExplicitCallToGetAtMethod": {}, | ||
"groovyism.ExplicitCallToLeftShiftMethod": {}, | ||
"groovyism.ExplicitCallToMinusMethod": {}, | ||
"groovyism.ExplicitCallToModMethod": {}, | ||
"groovyism.ExplicitCallToMultiplyMethod": {}, | ||
"groovyism.ExplicitCallToOrMethod": {}, | ||
"groovyism.ExplicitCallToPlusMethod": {}, | ||
"groovyism.ExplicitCallToPowerMethod": {}, | ||
"groovyism.ExplicitCallToPutAtMethod": {}, | ||
"groovyism.ExplicitCallToRightShiftMethod": {}, | ||
"groovyism.ExplicitCallToXorMethod": {}, | ||
"groovyism.ExplicitHashMapInstantiation": {}, | ||
"groovyism.ExplicitHashSetInstantiation": {}, | ||
"groovyism.ExplicitLinkedHashMapInstantiation": {}, | ||
"groovyism.ExplicitLinkedListInstantiation": {}, | ||
"groovyism.ExplicitStackInstantiation": {}, | ||
"groovyism.ExplicitTreeSetInstantiation": {}, | ||
"groovyism.GStringAsMapKey": {}, | ||
"groovyism.GStringExpressionWithinString": {}, | ||
"groovyism.GetterMethodCouldBeProperty": {}, | ||
"groovyism.GroovyLangImmutable": {}, | ||
"groovyism.UseCollectMany": {}, | ||
"groovyism.UseCollectNested": {}, | ||
"imports.DuplicateImport": {}, | ||
"imports.ImportFromSamePackage": {}, | ||
"imports.ImportFromSunPackages": {}, | ||
"imports.MisorderedStaticImports": {}, | ||
"imports.NoWildcardImports": {}, | ||
"imports.UnnecessaryGroovyImport": {}, | ||
"jdbc.DirectConnectionManagement": {}, | ||
"jdbc.JdbcConnectionReference": {}, | ||
"jdbc.JdbcResultSetReference": {}, | ||
"jdbc.JdbcStatementReference": {}, | ||
"junit.ChainedTest": {}, | ||
"junit.CoupledTestCase": {}, | ||
"junit.JUnitAssertAlwaysFails": {}, | ||
"junit.JUnitAssertAlwaysSucceeds": {}, | ||
"junit.JUnitFailWithoutMessage": {}, | ||
"junit.JUnitLostTest": {}, | ||
"junit.JUnitPublicField": {}, | ||
"junit.JUnitPublicNonTestMethod": {}, | ||
"junit.JUnitPublicProperty": {}, | ||
"junit.JUnitSetUpCallsSuper": {}, | ||
"junit.JUnitStyleAssertions": {}, | ||
"junit.JUnitTearDownCallsSuper": {}, | ||
"junit.JUnitTestMethodWithoutAssert": {}, | ||
"junit.JUnitUnnecessarySetUp": {}, | ||
"junit.JUnitUnnecessaryTearDown": {}, | ||
"junit.JUnitUnnecessaryThrowsException": {}, | ||
"junit.SpockIgnoreRestUsed": {}, | ||
"junit.UnnecessaryFail": {}, | ||
"junit.UseAssertEqualsInsteadOfAssertTrue": {}, | ||
"junit.UseAssertFalseInsteadOfNegation": {}, | ||
"junit.UseAssertNullInsteadOfAssertEquals": {}, | ||
"junit.UseAssertSameInsteadOfAssertTrue": {}, | ||
"junit.UseAssertTrueInsteadOfAssertEquals": {}, | ||
"junit.UseAssertTrueInsteadOfNegation": {}, | ||
"logging.LoggerForDifferentClass": {}, | ||
"logging.LoggerWithWrongModifiers": {}, | ||
"logging.LoggingSwallowsStacktrace": {}, | ||
"logging.MultipleLoggers": {}, | ||
"logging.PrintStackTrace": {}, | ||
"logging.Println": {}, | ||
"logging.SystemErrPrint": {}, | ||
"logging.SystemOutPrint": {}, | ||
"naming.AbstractClassName": {}, | ||
"naming.ClassName": {}, | ||
"naming.ClassNameSameAsFilename": {}, | ||
"naming.ClassNameSameAsSuperclass": {}, | ||
"naming.ConfusingMethodName": {}, | ||
"naming.FactoryMethodName": {}, | ||
"naming.FieldName": {}, | ||
"naming.InterfaceName": {}, | ||
"naming.InterfaceNameSameAsSuperInterface": {}, | ||
"naming.MethodName": {}, | ||
"naming.ObjectOverrideMisspelledMethodName": {}, | ||
"naming.PackageName": {}, | ||
"naming.PackageNameMatchesFilePath": {}, | ||
"naming.ParameterName": {}, | ||
"naming.PropertyName": {}, | ||
"naming.VariableName": {}, | ||
"security.FileCreateTempFile": {}, | ||
"security.InsecureRandom": {}, | ||
"security.JavaIoPackageAccess": {}, | ||
"security.NonFinalPublicField": {}, | ||
"security.NonFinalSubclassOfSensitiveInterface": {}, | ||
"security.ObjectFinalize": {}, | ||
"security.PublicFinalizeMethod": {}, | ||
"security.SystemExit": {}, | ||
"security.UnsafeArrayDeclaration": {}, | ||
"serialization.EnumCustomSerializationIgnored": {}, | ||
"serialization.SerialPersistentFields": {}, | ||
"serialization.SerialVersionUID": {}, | ||
"serialization.SerializableClassMustDefineSerialVersionUID": {}, | ||
"size.ClassSize": {}, | ||
"size.MethodCount": {}, | ||
"size.MethodSize": {}, | ||
"size.NestedBlockDepth": {}, | ||
"size.ParameterCount": {}, | ||
"unnecessary.AddEmptyString": {}, | ||
"unnecessary.ConsecutiveLiteralAppends": {}, | ||
"unnecessary.ConsecutiveStringConcatenation": {}, | ||
"unnecessary.UnnecessaryBigDecimalInstantiation": {}, | ||
"unnecessary.UnnecessaryBigIntegerInstantiation": {}, | ||
"unnecessary.UnnecessaryBooleanExpression": {}, | ||
"unnecessary.UnnecessaryBooleanInstantiation": {}, | ||
"unnecessary.UnnecessaryCallForLastElement": {}, | ||
"unnecessary.UnnecessaryCallToSubstring": {}, | ||
"unnecessary.UnnecessaryCast": {}, | ||
"unnecessary.UnnecessaryCatchBlock": {}, | ||
"unnecessary.UnnecessaryCollectCall": {}, | ||
"unnecessary.UnnecessaryCollectionCall": {}, | ||
"unnecessary.UnnecessaryConstructor": {}, | ||
"unnecessary.UnnecessaryDefInFieldDeclaration": {}, | ||
"unnecessary.UnnecessaryDefInMethodDeclaration": {}, | ||
"unnecessary.UnnecessaryDefInVariableDeclaration": {}, | ||
"unnecessary.UnnecessaryDotClass": {}, | ||
"unnecessary.UnnecessaryDoubleInstantiation": {}, | ||
"unnecessary.UnnecessaryElseStatement": {}, | ||
"unnecessary.UnnecessaryFinalOnPrivateMethod": {}, | ||
"unnecessary.UnnecessaryFloatInstantiation": {}, | ||
"unnecessary.UnnecessaryGString": {}, | ||
"unnecessary.UnnecessaryGetter": {}, | ||
"unnecessary.UnnecessaryIfStatement": {}, | ||
"unnecessary.UnnecessaryInstanceOfCheck": {}, | ||
"unnecessary.UnnecessaryInstantiationToGetClass": {}, | ||
"unnecessary.UnnecessaryIntegerInstantiation": {}, | ||
"unnecessary.UnnecessaryLongInstantiation": {}, | ||
"unnecessary.UnnecessaryModOne": {}, | ||
"unnecessary.UnnecessaryNullCheck": {}, | ||
"unnecessary.UnnecessaryNullCheckBeforeInstanceOf": {}, | ||
"unnecessary.UnnecessaryObjectReferences": {}, | ||
"unnecessary.UnnecessaryOverridingMethod": {}, | ||
"unnecessary.UnnecessaryPackageReference": {}, | ||
"unnecessary.UnnecessaryParenthesesForMethodCallWithClosure": {}, | ||
"unnecessary.UnnecessaryPublicModifier": {}, | ||
"unnecessary.UnnecessaryReturnKeyword": {}, | ||
"unnecessary.UnnecessarySafeNavigationOperator": {}, | ||
"unnecessary.UnnecessarySelfAssignment": {}, | ||
"unnecessary.UnnecessarySemicolon": {}, | ||
"unnecessary.UnnecessarySetter": {}, | ||
"unnecessary.UnnecessaryStringInstantiation": {}, | ||
"unnecessary.UnnecessarySubstring": {}, | ||
"unnecessary.UnnecessaryTernaryExpression": {}, | ||
"unnecessary.UnnecessaryToString": {}, | ||
"unnecessary.UnnecessaryTransientModifier": {}, | ||
"unused.UnusedArray": {}, | ||
"unused.UnusedMethodParameter": {}, | ||
"unused.UnusedObject": {}, | ||
"unused.UnusedPrivateField": {}, | ||
"unused.UnusedPrivateMethod": {}, | ||
"unused.UnusedPrivateMethodParameter": {}, | ||
"unused.UnusedVariable": {} | ||
"convention.NoDef": "off", | ||
"convention.VariableTypeRequired": "off", | ||
"dry.DuplicateStringLiteral": "off", | ||
"formatting.LineLength": "off", | ||
"logging.Println": "off" | ||
} | ||
} |
@@ -8,3 +8,3 @@ // Shared functions | ||
const xml2js = require("xml2js"); | ||
const { npmGroovyLintRules } = require("./groovy-lint-rules.js"); | ||
const { getNpmGroovyLintRules } = require("./groovy-lint-rules.js"); | ||
const { evaluateRange, evaluateVariables, getSourceLines } = require("./utils.js"); | ||
@@ -16,2 +16,4 @@ | ||
const npmGroovyLintRules = getNpmGroovyLintRules(); | ||
// Convert NPM-groovy-lint into codeNarc arguments | ||
@@ -18,0 +20,0 @@ // Create temporary files if necessary |
@@ -26,9 +26,18 @@ // Configuration file management | ||
// Load user configuration from file | ||
const configUser = await loadConfigFromFile(configFilePath); | ||
let configUser = await loadConfigFromFile(configFilePath); | ||
configUser.rules = await shortenRuleNames(configUser.rules || {}); | ||
// If config extends a standard one, merge it | ||
configUser = await manageExtends(configUser); | ||
return configUser; | ||
} | ||
// If extends defined, gather base level rules and append them to current rules | ||
async function manageExtends(configUser) { | ||
if (configUser.extends) { | ||
const baseConfigFilePath = await findConfigInPath(__dirname, [`.groovylintrc-${configUser.extends}.json`]); | ||
const baseConfig = await loadConfigFromFile(baseConfigFilePath); | ||
let baseConfig = await loadConfigFromFile(baseConfigFilePath); | ||
baseConfig.rules = await shortenRuleNames(baseConfig.rules || {}); | ||
// A config can extend another config that extends another config | ||
baseConfig = await manageExtends(baseConfig); | ||
// Delete doublons | ||
for (const baseRuleName of Object.keys(baseConfig.rules)) { | ||
@@ -42,2 +51,3 @@ for (const userRuleName of Object.keys(configUser.rules)) { | ||
configUser.rules = Object.assign(baseConfig.rules, configUser.rules); | ||
delete configUser.extends; | ||
} | ||
@@ -44,0 +54,0 @@ return configUser; |
@@ -7,3 +7,3 @@ #! /usr/bin/env node | ||
const debug = require("debug")("npm-groovy-lint"); | ||
const { npmGroovyLintRules } = require("./groovy-lint-rules.js"); | ||
const { getNpmGroovyLintRules } = require("./groovy-lint-rules.js"); | ||
const { evaluateVariables, getSourceLines } = require("./utils.js"); | ||
@@ -32,3 +32,3 @@ | ||
// Load available fix rules | ||
this.npmGroovyLintRules = this.options.groovyLintRulesOverride ? require(this.options.groovyLintRulesOverride) : npmGroovyLintRules; | ||
this.npmGroovyLintRules = this.options.groovyLintRulesOverride ? require(this.options.groovyLintRulesOverride) : getNpmGroovyLintRules(); | ||
if (this.options.fixrules && this.options.fixrules !== "all") { | ||
@@ -35,0 +35,0 @@ this.fixRules = this.options.fixrules.split(","); |
@@ -85,3 +85,3 @@ // Additional definition for codenarc rules ( get position & available fix) | ||
// If you add a new global rule, it's very important to think about their order. | ||
// If you add a new global rule with a fix function, it's very important to think about their order. | ||
// Rules modifiyng the number of lines must arrive last ! | ||
@@ -93,2 +93,3 @@ const rulesFixPriorityOrder = [ | ||
"UnnecessaryGString", | ||
"UnnecessaryToString", | ||
"SpaceBeforeOpeningBrace", | ||
@@ -104,8 +105,10 @@ "SpaceAfterOpeningBrace", | ||
// Rule that can change the numbers of lines, so they must be processed after line scope rules | ||
"UnnecessaryGroovyImport", | ||
"UnusedImport", | ||
"IfStatementBraces", | ||
"ElseBlocktBraces", | ||
"ConsecutiveBlankLines", | ||
"ClosingBraceNotAlone", | ||
"IndentationClosingBraces", | ||
"IndentationComments", | ||
"ConsecutiveBlankLines", | ||
"FileEndsWithoutNewline" | ||
@@ -116,14 +119,23 @@ ]; | ||
const ruleFiles = fse.readdirSync(RULES_FOLDER); | ||
const npmGroovyLintRules = {}; | ||
for (const file of ruleFiles) { | ||
const ruleName = file.replace(".js", ""); | ||
const { rule } = require(`${RULES_FOLDER}/${file}`); | ||
if (rule.disabled) { | ||
continue; | ||
function getNpmGroovyLintRules(optns = {}) { | ||
const ruleFiles = fse.readdirSync(RULES_FOLDER); | ||
const npmGroovyLintRules = {}; | ||
for (const file of ruleFiles) { | ||
const ruleName = file.replace(".js", ""); | ||
const { rule } = require(`${RULES_FOLDER}/${file}`); | ||
if (rule.disabled) { | ||
continue; | ||
} | ||
rule.priority = rulesFixPriorityOrder.indexOf(ruleName); | ||
if (rule.fix && rule.priority < 0) { | ||
throw new Error(`Rule ${ruleName} must have an order defined in groovy-lint-rules.js/rulesFixPriorityOrder`); | ||
} | ||
if (!optns.loadTests && optns.loadTests === true) { | ||
delete rule.tests; | ||
} | ||
npmGroovyLintRules[ruleName] = rule; | ||
} | ||
rule.priority = rulesFixPriorityOrder.indexOf(ruleName); | ||
npmGroovyLintRules[ruleName] = rule; | ||
return npmGroovyLintRules; | ||
} | ||
module.exports = { npmGroovyLintRules }; | ||
module.exports = { getNpmGroovyLintRules }; |
@@ -71,4 +71,6 @@ #! /usr/bin/env node | ||
async fixErrors(errorIds, optns = {}) { | ||
// Run fixer on existing NpmGroovyLint instance | ||
// Create and run fixer | ||
debug(`Fix errors for ${JSON.stringify(errorIds)} on existing NpmGroovyLint instance`); | ||
const codeNarcFactoryResult = await prepareCodeNarcCall(this.options, this.jdeployRootPath); | ||
this.setMethodResult(codeNarcFactoryResult); | ||
this.fixer = new NpmGroovyLintFix(this.lintResult, { | ||
@@ -82,4 +84,7 @@ verbose: optns.verbose || this.options.verbose, | ||
this.lintResult = this.fixer.updatedLintResult; | ||
// Control fix result by calling a new lint | ||
await this.lintAgainAfterFix(); | ||
// Lint again after fix if requested (for the moment we prefer to trigger that from VsCode, for better UX) | ||
if (optns.lintAgainAfterFix) { | ||
// Control fix result by calling a new lint | ||
await this.lintAgainAfterFix(); | ||
} | ||
// Compute stats & build output result | ||
@@ -86,0 +91,0 @@ this.lintResult = computeStats(this.lintResult); |
{ | ||
"name": "npm-groovy-lint", | ||
"version": "3.0.1-beta.4", | ||
"version": "3.0.1", | ||
"description": "NPM CodeNarc wrapper to easily lint Groovy files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
16270342
3480