Inspection "Hard coded strings" - ignore for Annotations

Answered

Hello,

I am pretty sure that in "some" previous version (probably before 2019) strings that were assigned to annotation methods were not caught be the Hard coded strings inspection. Right now the are caught, so that I get two warnings in the following class (in @Table and @Colum, both from javax.persistence):

@Entity
@Table(name = "ic_machines")
public class MachineDTO {

  @Id
  @Column(name = "machine_id")
  private int id;

  public MachineDTO(int id) {
    this.id = id;
  }
}

 

Is there any option to ignore the inspection for exactly all strings that are assigned to annotation methods? These strings obviously cannot be internationalized because you are not allowed to use anything but a "true" constant for the right side of the assignment.

Thanks in advance

0
1 comment

Hello,

You may explicitly mark the code elements to be localized with `@Nls` annotation. And while running the inspection ignore all the elements not annotated with this annotation.

Please tell if this workaround solves the issue for you?

Please also follow the feature request created for your report: https://youtrack.jetbrains.com/issue/IDEA-252485

Thank you 

0

Please sign in to leave a comment.