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:
