Skip to content

Commit

Permalink
Merge pull request #779 from danielzaenker/rename-rules
Browse files Browse the repository at this point in the history
Rename rules NotAllFieldsOfSerializableClassSerializable and OverridesNotNonCps
  • Loading branch information
chrismair authored Mar 31, 2024
2 parents fd328da + 5eb2825 commit d4af7c4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docs/codenarc-rules-jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void cpsMethod() {
}
```

## OverridesNotNonCps Rule
## ObjectOverrideOnlyNonCpsMethods Rule

*Since CodeNarc 3.5.0*

Expand Down
2 changes: 1 addition & 1 deletion docs/codenarc-rules-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ An example of a missing serialVersionUID:
}
```

## NotAllFieldsOfSerializableClassSerializable Rule
## NonSerializableFieldInSerializableClass Rule

*Since CodeNarc 3.5.0*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ import org.codenarc.rule.AbstractMethodVisitor
*
* @author Daniel Zänker
*/
class OverridesNotNonCpsRule extends AbstractAstVisitorRule {
class ObjectOverrideOnlyNonCpsMethods extends AbstractAstVisitorRule {

String name = 'OverridesNotNonCps'
String name = 'ObjectOverrideOnlyNonCpsMethods'
int priority = 2
Class astVisitorClass = OverridesNotNonCpsAstVisitor
Class astVisitorClass = ObjectOverrideOnlyNonCpsMethodsVisitor
int compilerPhase = Phases.SEMANTIC_ANALYSIS
String applyToFileNames = 'Jenkinsfile'
}

class OverridesNotNonCpsAstVisitor extends AbstractMethodVisitor {
class ObjectOverrideOnlyNonCpsMethodsVisitor extends AbstractMethodVisitor {
final static List<Map> OBJECT_METHODS = [
[name: 'clone', parameters: []],
[name: 'equals', parameters: [ClassHelper.make(Object)]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import org.codenarc.util.AstUtil
*
* @author Daniel Zänker
*/
class NotAllFieldsOfSerializableClassSerializableRule extends AbstractAstVisitorRule {
class NonSerializableFieldInSerializableClass extends AbstractAstVisitorRule {

String name = 'NotAllFieldsOfSerializableClassSerializable'
String name = 'NonSerializableFieldInSerializableClass'
int priority = 2
Class astVisitorClass = NotAllFieldsOfSerializableClassSerializableAstVisitor
Class astVisitorClass = NonSerializableFieldInSerializableClassVisitor
int compilerPhase = Phases.SEMANTIC_ANALYSIS
}

class NotAllFieldsOfSerializableClassSerializableAstVisitor extends AbstractAstVisitor {
class NonSerializableFieldInSerializableClassVisitor extends AbstractAstVisitor {

@Override
void visitField(FieldNode field) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/codenarc-base-messages.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
NotAllFieldsOfSerializableClassSerializable.description=All fields of a class that implements Serializable should also implement it
NotAllFieldsOfSerializableClassSerializable.description.html=All fields of a class that implements Serializable should also implement it
NonSerializableFieldInSerializableClass.description=All fields of a class that implements Serializable should also implement it
NonSerializableFieldInSerializableClass.description.html=All fields of a class that implements Serializable should also implement it

ParameterOrReturnTypeNotSerializable.description=Every parameter and return type has to implement the Serializable interface in Jenkins
ParameterOrReturnTypeNotSerializable.description.html=Every parameter and return type has to implement the Serializable interface in Jenkins

OverridesNotNonCps.description=Overridden methods of the standard library (e.g. from java.lang.Object) are often called from there and therefore must not be CPS transformed in Jenkins
OverridesNotNonCps.description.html=Overridden methods of the standard library (e.g. from java.lang.Object) are often called from there and therefore must not be CPS transformed in Jenkins
ObjectOverrideOnlyNonCpsMethods.description=Overridden methods of the standard library (e.g. from java.lang.Object) are often called from there and therefore must not be CPS transformed in Jenkins
ObjectOverrideOnlyNonCpsMethods.description.html=Overridden methods of the standard library (e.g. from java.lang.Object) are often called from there and therefore must not be CPS transformed in Jenkins

ForbiddenCallInCpsMethod.description=Some methods from the standard library cannot be CPS transformed and therefore must not be called from CPS transformed methods in Jenkins
ForbiddenCallInCpsMethod.description.html=Some methods from the standard library cannot be CPS transformed and therefore must not be called from CPS transformed methods in Jenkins
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/codenarc-base-rules.properties
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ NoTabCharacter = org.codenarc.rule.convention.NoTabCharacterRule
NoWildcardImports = org.codenarc.rule.imports.NoWildcardImportsRule
NonFinalPublicField = org.codenarc.rule.security.NonFinalPublicFieldRule
NonFinalSubclassOfSensitiveInterface = org.codenarc.rule.security.NonFinalSubclassOfSensitiveInterfaceRule
NotAllFieldsOfSerializableClassSerializable = org.codenarc.rule.serialization.NotAllFieldsOfSerializableClassSerializableRule
NonSerializableFieldInSerializableClass = org.codenarc.rule.serialization.NonSerializableFieldInSerializableClass
ObjectFinalize = org.codenarc.rule.security.ObjectFinalizeRule
ObjectOverrideMisspelledMethodName = org.codenarc.rule.naming.ObjectOverrideMisspelledMethodNameRule
OptionalCollectionReturnType = org.codenarc.rule.design.OptionalCollectionReturnTypeRule
OptionalField = org.codenarc.rule.design.OptionalFieldRule
OptionalMethodParameter = org.codenarc.rule.design.OptionalMethodParameterRule
OverridesNotNonCps = org.codenarc.rule.jenkins.OverridesNotNonCpsRule
ObjectOverrideOnlyNonCpsMethods = org.codenarc.rule.jenkins.ObjectOverrideOnlyNonCpsMethods
PackageName = org.codenarc.rule.naming.PackageNameRule
PackageNameMatchesFilePath = org.codenarc.rule.naming.PackageNameMatchesFilePathRule
ParameterAssignmentInFilterClosure = org.codenarc.rule.basic.ParameterAssignmentInFilterClosureRule
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/rulesets/jenkins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</description>

<rule class='org.codenarc.rule.jenkins.ParameterOrReturnTypeNotSerializableRule'/>
<rule class='org.codenarc.rule.jenkins.OverridesNotNonCpsRule'/>
<rule class='org.codenarc.rule.jenkins.ObjectOverrideOnlyNonCpsMethods'/>
<rule class='org.codenarc.rule.jenkins.ForbiddenCallInCpsMethodRule'/>
<rule class='org.codenarc.rule.jenkins.ExpressionInCpsMethodNotSerializableRule'/>
<rule class='org.codenarc.rule.jenkins.CpsCallFromNonCpsMethodRule'/>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/rulesets/serialization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</description>

<rule class='org.codenarc.rule.serialization.EnumCustomSerializationIgnoredRule'/>
<rule class='org.codenarc.rule.serialization.NotAllFieldsOfSerializableClassSerializableRule'/>
<rule class='org.codenarc.rule.serialization.NonSerializableFieldInSerializableClass'/>
<rule class='org.codenarc.rule.serialization.SerialPersistentFieldsRule'/>
<rule class='org.codenarc.rule.serialization.SerialVersionUIDRule'/>
<rule class='org.codenarc.rule.serialization.SerializableClassMustDefineSerialVersionUIDRule'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ package org.codenarc.rule.jenkins
import org.junit.jupiter.api.Test

/**
* Tests for OverridesNotNonCpsRule
* Tests for ObjectOverrideOnlyNonCpsMethods
*
* Note: Usage of com.cloudbees.groovy.cps.NonCPS intentionally commented out for test purposes to mark where it would be used in a real use case.
* This is necessary because we don't want to add this to the test dependencies.
*
* @author Daniel Zänker
*/
class OverridesNotNonCpsRuleTest extends AbstractJenkinsRuleTestCase<OverridesNotNonCpsRule> {
class ObjectOverrideOnlyNonCpsMethodsTest extends AbstractJenkinsRuleTestCase<ObjectOverrideOnlyNonCpsMethods> {

@Test
void testRuleProperties() {
assert rule.priority == 2
assert rule.name == 'OverridesNotNonCps'
assert rule.name == 'ObjectOverrideOnlyNonCpsMethods'
}

@Test
Expand Down Expand Up @@ -111,7 +111,7 @@ class OverridesNotNonCpsRuleTest extends AbstractJenkinsRuleTestCase<OverridesNo
}

@Override
protected OverridesNotNonCpsRule createRule() {
new OverridesNotNonCpsRule()
protected ObjectOverrideOnlyNonCpsMethods createRule() {
new ObjectOverrideOnlyNonCpsMethods()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import org.codenarc.rule.AbstractRuleTestCase
import org.junit.jupiter.api.Test

/**
* Tests for NotAllFieldsOfSerializableClassSerializableRule
* Tests for NonSerializableFieldInSerializableClass
*
* @author Daniel Zänker
*/
class NotAllFieldsOfSerializableClassSerializableRuleTest extends AbstractRuleTestCase<NotAllFieldsOfSerializableClassSerializableRule> {
class NonSerializableFieldInSerializableClassTest extends AbstractRuleTestCase<NonSerializableFieldInSerializableClass> {

@Test
void testRuleProperties() {
assert rule.priority == 2
assert rule.name == 'NotAllFieldsOfSerializableClassSerializable'
assert rule.name == 'NonSerializableFieldInSerializableClass'
}

@Test
Expand Down Expand Up @@ -98,7 +98,7 @@ class NotAllFieldsOfSerializableClassSerializableRuleTest extends AbstractRuleTe
}

@Override
protected NotAllFieldsOfSerializableClassSerializableRule createRule() {
new NotAllFieldsOfSerializableClassSerializableRule()
protected NonSerializableFieldInSerializableClass createRule() {
new NonSerializableFieldInSerializableClass()
}
}

0 comments on commit d4af7c4

Please sign in to comment.