I'm trying to find all the places in a project where a constant could be introduced, because a String literal is being overused.
I'm aware of the Refactor > Introduce Constant... (Ctrl Alt C) function that Intellij has. But I can't find a way to search massively for these places where this function would make sense to be applied. Thanks
CodePudding user response:
For IntelliJ Ultimate:
For IntelliJ Community:
By exploiting the localization (translation) feature, you can find all string duplicates... This isn't as robust as the Ultimate "duplicate code" feature -- which is capable of detecting duplicate code blocks -- but can help for quickly finding duplicates strings in a project.
Preferences | Editor | Inspections | Java | Internationalization | Duplicate String Literal
- Click the checkbox to enable ☑
- Set the minimum string length value (it defaults to 5 characters)
- Change the warning level to