Changing the case of letters in a folder name makes sonarcloud treat all the files in the folder as new code

I had a folder called “myorg.something.else” and renamed it to “MyOrg.Something.Else” by using git mv commands. Git has it recorded as a movement/rename and has preserved history.

When I pushed the branch for PR and had sonar run on it, it considered all of the files in the folder as new code, which fails the new code quality gate for several reasons.

This was existing C# code, the code in the files was not touched, only the parent folder renamed. Git history shows that this is what happened.

I shouldnt have to disable the sonar checking on my build pipelines in order to work around it.

Hi @StingyJack , SonarCloud compare the file changes to detect new code, we don’t use git history. When renaming a folder it will be considered as new code, even if it is a refactor for instance.

I hope that help.

But it’s not new code, it’s existing code that has moved that Sonar is now classifying incorrectly and reporting incorrectly.

It’s going to make me want to avoid refactoring and cleaning as I code.

Hello @StingyJack ,

This is currently a limitation on our side, and something we want to improve upon in the future. We’ve added your use-case / insights to our internal ticket. Unfortunately I can’t promise anything in the short term.

1 Like