2

I know how to disable star imports in IntelliJ: IntelliJ: Never use wildcard imports

However, each developer from my team must do it manually for every language (Java, Groovy, etc.) and for me this is wasting their time.

Is there some way to let IDEA know via Gradle or file in repository in .idea directory to never use star imports in some particular project?

Michal Kordas
  • 10,475
  • 7
  • 58
  • 103

1 Answers1

1

You can do it with two files in project's .idea folder:

.idea/codeStyles
├── codeStyleConfig.xml
└── Project.xml

.idea/codeStyles/Project.xml

<component name="ProjectCodeStyleConfiguration">
  <code_scheme name="Project" version="173">
    <GroovyCodeStyleSettings>
      <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />
      <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />
    </GroovyCodeStyleSettings>
    <JavaCodeStyleSettings>
      <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />
      <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />
    </JavaCodeStyleSettings>
  </code_scheme>
</component>

.idea/codeStyles/codeStyleConfig.xml

<component name="ProjectCodeStyleConfiguration">
  <state>
    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Project" />
  </state>
</component>

In this example I set the limit to 500 classes for Java and Groovy programming languages:

enter image description here

Szymon Stepniak
  • 40,216
  • 10
  • 104
  • 131