diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
index fb81e1046f06..b15119516f8f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
@@ -32,6 +32,7 @@ import com.intellij.testFramework.InspectionsKt;
import com.intellij.testFramework.LightIdeaTestCase;
import com.intellij.util.JdomKt;
import com.intellij.util.SmartList;
+import com.siyeh.ig.naming.ClassNamingConvention;
import com.siyeh.ig.naming.NewClassNamingConventionInspection;
import org.jdom.Element;
import org.jdom.JDOMException;
@@ -342,11 +343,6 @@ public class InspectionProfileTest extends LightIdeaTestCase {
" \n" +
" \n" +
" \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
" \n" +
" \n" +
" \n" +
@@ -370,10 +366,11 @@ public class InspectionProfileTest extends LightIdeaTestCase {
InspectionToolWrapper wrapper = profile.getInspectionTool("NewClassNamingConvention", getProject());
assertNotNull(wrapper);
NewClassNamingConventionInspection tool = (NewClassNamingConventionInspection)wrapper.getTool();
- assertEquals(256, tool.getNamingConventionBean("ClassNamingConvention").m_maxLength);
+ assertEquals(256, tool.getNamingConventionBean("AnnotationNamingConvention").m_maxLength);
assertEquals(1, tool.getNamingConventionBean("EnumeratedClassNamingConvention").m_minLength);
assertTrue(profile.isToolEnabled(HighlightDisplayKey.find("NewClassNamingConvention"), null));
assertFalse(tool.isConventionEnabled("TypeParameterNamingConvention"));
+ assertFalse(tool.isConventionEnabled(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME));
Element toImportElement = profile.writeScheme();
final InspectionProfileImpl importedProfile =
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NewClassNamingConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NewClassNamingConventionInspection.java
index 192cdd6ca472..813055ce57c6 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NewClassNamingConventionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NewClassNamingConventionInspection.java
@@ -67,12 +67,12 @@ public class NewClassNamingConventionInspection extends BaseInspection {
myNamingConventionBeans.put(convention.getShortName(), convention.createDefaultBean());
}
initDisabledState();
+ myDisabledShortNames.remove(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
}
private void initDisabledState() {
myDisabledShortNames.clear();
myDisabledShortNames.addAll(myNamingConventions.keySet());
- myDisabledShortNames.remove(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
}
public NamingConventionBean getNamingConventionBean(String shortName) {
@@ -133,7 +133,7 @@ public class NewClassNamingConventionInspection extends BaseInspection {
XmlSerializer.serializeInto(conventionBean, element);
}
else {
- if (shortName.equals(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME) != disabled) continue;
+ if (disabled) continue;
}
node.addContent(element);
}
@@ -161,11 +161,15 @@ public class NewClassNamingConventionInspection extends BaseInspection {
if (myDisabledShortNames.contains(shortName)) {
break;
}
- NamingConventionBean conventionBean = myNamingConventionBeans.get(shortName);
- NamingConventionBean activeConventionBean =
- conventionBean instanceof NamingConventionWithFallbackBean && ((NamingConventionWithFallbackBean)conventionBean).isInheritDefaultSettings()
- ? myNamingConventionBeans.get(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME) : conventionBean;
- if (!activeConventionBean.isValid(name)) {
+ NamingConventionBean activeBean = myNamingConventionBeans.get(shortName);
+ if (activeBean instanceof NamingConventionWithFallbackBean && ((NamingConventionWithFallbackBean)activeBean).isInheritDefaultSettings()) {
+ //disabled when fallback is disabled
+ if (myDisabledShortNames.contains(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME)) {
+ break;
+ }
+ activeBean = myNamingConventionBeans.get(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
+ }
+ if (!activeBean.isValid(name)) {
registerClassError(aClass, name, shortName);
}
break;