devonfw / sonar-devon4j-plugin

Plugin for SonarQube to validate devonfw architecture
Apache License 2.0
10 stars 16 forks source link

devon formatter not having same values like Sonar plugin #136

Open rhobolic opened 2 years ago

rhobolic commented 2 years ago

If I'm using the devon ide (devon4j) without touching everything I get issues in Sonar though I use the devon sonar plugin also without changes.

Problem description: As an example here is to take the checkstyle rule which is also part of devon java profile "Intendation". When I look into the profile I see the following configuration. image But if I look into the formatter in the ide there is the following configuration image Therefore Sonar is throwing an issue. There are also other issues like "Import order" or "Line length"

Expectation Devon ide, devon formatter and devon sonar plugin have the same values and work out of the box without throwing issues.

hohwille commented 2 years ago

@rhobolic thanks for reporting this bug. Indeed this is very odd and kind of frustrating. I am not sure why this happened. Indentation in devonfw has been 2 white spaces from the very beginning (even in oasp4j). After all the default rules and especially the whitespace rules for checkstyle are defined here: https://github.com/devonfw/sonar-devon4j-plugin/blob/3bd6482d1164e7d915ec4d10779eeda6235316fe/src/main/resources/com/devonfw/ide/sonarqube/common/rules/devon4j/devon4j.xml#L703

As we can see the parameters are simply wrong: https://github.com/devonfw/sonar-devon4j-plugin/blob/3bd6482d1164e7d915ec4d10779eeda6235316fe/src/main/resources/com/devonfw/ide/sonarqube/common/rules/devon4j/devon4j.xml#L729

I will simply change this and set the indentation to 2 instead of 4.

BTW:

If I'm using the devon ide (devon4j) without touching everything I get issues in Sonar though I use the devon sonar plugin also without changes.

As a lot of people seemed to get confused with devonfw artifacts here are some hints to match them properly:

hohwille commented 2 years ago

For the record: There are several very picky checkstyle rules active in our config that should also be discussed:

There might be more in this regard. I can do some testing on this and file a new issue for it if applicable...

hohwille commented 2 years ago

I assume that this issue is fixed and can be closed. However, my tests are currently blocked by #141.

hohwille commented 2 years ago

Another interesting fact is that the file that I initially created came from here and is still present: https://github.com/devonfw/ide-settings/blob/master/sonarqube/profiles/Devon-Java.xml

It has correct indentation configured and lots of other differences. So something went wrong when PR #56 was implemented.