Code Inspection: Naming rules are not applied deterministically
The code inspection step does not apply the naming rules described in CleanCode.sln.dotsettings according to a consistent scheme.
We have two rules specified but it seems that only one of them is getting applied.
Example: <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="m_" Suffix="Id" Style="AaBb_AaBb"><ExtraRule Prefix="m_" Suffix="" Style="AaBb_AaBb" /></Policy></s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="s_" Suffix="Id" Style="AaBb_AaBb"><ExtraRule Prefix="s_" Suffix="" Style="AaBb_AaBb" /></Policy></s:String>
With that Code:
[TestFixture] public class InspectionTest { private int m_Id = 15; private static int s_Id = 30; [Test] public void Then_it_should() { Assert.AreEqual(15, m_Id); Assert.AreEqual(30, s_Id); } }
We are getting the following Inspection-Errors:
Name 'm_Id' does not match rule 'Instance fields (private)'. Suggested name is 'm_'.
Name 's_Id' does not match rule 'Static fields (private)'. Suggested name is 's_'.
From our understanding, m_Id should be a valid name. After changing the field names to m_Idx and s_Idx, the inspection error disappears. If you then revert again, there will no longer be an inspection error.
Please contact us for more information. How can this behavior be explained?
Please sign in to leave a comment.
Hi,
Could you kindly export the entire CleanCode.sln.dotsettings file and upload it via https://uploads.jetbrains.com/?
Once uploaded, please provide us with the exact ID.
Meanwhile, you can utilize the ReSharper Command Line Tools to run the following command locally. And check if you encounter the same behavior as observed in TeamCity.
InspectCode.exe YourSolution.sln -o=<PathToOutputFile>For more detailed information, please refer to Run InspectCode .
sorry for my late response, i opened a ticket:
Code Inspections: Naming rules are not applied deterministically : RSRP-496896 (jetbrains.com)