Skip to content

ConstantsAndStaticNonFinalFieldsNamesRule: Synthetic/Anonymous class violate the rule #90

@fhaefemeier

Description

@fhaefemeier

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 TNG/ArchUnit#1019

Type of Issue

It is a :

  • 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions