arch-unit-build-plugin-core icon indicating copy to clipboard operation
arch-unit-build-plugin-core copied to clipboard

ConstantsAndStaticNonFinalFieldsNamesRule: Synthetic/Anonymous class violate the rule

Open fhaefemeier opened this issue 10 months ago • 0 comments

Summary

Have a method with the following code snippet:

package de.dummy;
public class CheckDummy {
  public void check(DummyEnum dummy) {
     var check = switch (dummy) {
         default -> true;
     };
  }
}

de.dummy.DummyEnum is a enumeration. Running ArchUnit with ConstantsAndStaticNonFinalFieldsNamesRule enabled, it prints the error

[ERROR] Constants have to be written in uppercase. It's possible to add underscore but not at the beginning or the end of the name. - class: de.dummy.CheckDummy$1 - field name: $SwitchMap$de$dummy$DummyEnum

It seems related to https://github.com/TNG/ArchUnit/issues/1019

Type of Issue

It is a :

  • [x] bug
  • [ ] request
  • [ ] question regarding the documentation

Motivation

Current Behavior

Running ArchUnit with ConstantsAndStaticNonFinalFieldsNamesRule enabled, it prints the error

[ERROR] Constants have to be written in uppercase. It's possible to add underscore but not at the beginning or the end of the name. - class: de.dummy.CheckDummy$1 - field name: $SwitchMap$de$dummy$DummyEnum

Expected Behavior

Expected behaviour should accept this special case as a valid exception.

Steps to Reproduce (for bugs)

Your Environment

  • Version used: arch-unit-maven-plugin:3.0.2
  • OS and version: JDK17
  • Version of libs used:

fhaefemeier avatar Apr 21 '24 16:04 fhaefemeier