-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sonar: add java backend and frontend sonar configuration
- Loading branch information
1 parent
9f6ce9a
commit d7915f0
Showing
8 changed files
with
169 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/resources/generator/server/sonar/sonar-fullstack-project.properties.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
sonar.projectKey={{baseName}} | ||
sonar.projectName={{projectName}} | ||
|
||
sonar.sources=src/main/ | ||
sonar.tests=src/test/ | ||
sonar.host.url=http://localhost:9001 | ||
|
||
sonar.test.inclusions=src/test/**/*.*, src/main/webapp/app/**/*.spec.ts | ||
sonar.coverage.jacoco.xmlReportPaths=target/jacoco/jacoco.xml | ||
sonar.java.codeCoveragePlugin=jacoco | ||
sonar.junit.reportPaths=target/surefire-reports,target/failsafe-reports | ||
|
||
sonar.testExecutionReportPaths=target/test-results/jest/TESTS-results-sonar.xml | ||
sonar.javascript.lcov.reportPaths=target/test-results/lcov.info | ||
|
||
sonar.sourceEncoding=UTF-8 | ||
sonar.exclusions=src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, src/main/webapp/i18n/*.js, target/classes/static/**/*.* | ||
|
||
sonar.issue.ignore.multicriteria=S3437,S4502,S4684,S4032,UndocumentedApi | ||
|
||
# Rule https://rules.sonarsource.com/java/RSPEC-3437 is ignored, as a JPA-managed field cannot be transient | ||
sonar.issue.ignore.multicriteria.S3437.resourceKey=src/main/java/**/* | ||
sonar.issue.ignore.multicriteria.S3437.ruleKey=squid:S3437 | ||
|
||
# Rule https://rules.sonarsource.com/java/RSPEC-1176 is ignored, as we want to follow "clean code" guidelines and classes, methods and arguments names should be self-explanatory | ||
sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey=src/main/java/**/* | ||
sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey=squid:UndocumentedApi | ||
|
||
# Rule https://rules.sonarsource.com/java/RSPEC-4502 is ignored, as for JWT tokens we are not subject to CSRF attack | ||
sonar.issue.ignore.multicriteria.S4502.resourceKey=src/main/java/**/* | ||
sonar.issue.ignore.multicriteria.S4502.ruleKey=java:S4502 | ||
|
||
# Rule https://rules.sonarsource.com/java/RSPEC-4684 | ||
sonar.issue.ignore.multicriteria.S4684.resourceKey=src/main/java/**/* | ||
sonar.issue.ignore.multicriteria.S4684.ruleKey=java:S4684 | ||
|
||
# Rule: Packages containing only "package-info.java" should be removed | ||
sonar.issue.ignore.multicriteria.S4032.resourceKey=src/main/java/**/* | ||
sonar.issue.ignore.multicriteria.S4032.ruleKey=java:S4032 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/test/java/tech/jhipster/lite/generator/server/sonar/application/SonarAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package tech.jhipster.lite.generator.server.sonar.application; | ||
|
||
import static tech.jhipster.lite.TestUtils.assertFileContent; | ||
import static tech.jhipster.lite.TestUtils.assertFileExist; | ||
import static tech.jhipster.lite.generator.project.domain.Constants.POM_XML; | ||
|
||
import java.util.List; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
|
||
public class SonarAssert { | ||
|
||
private SonarAssert() {} | ||
|
||
public static void assertFiles(Project project) { | ||
assertFileExist(project, "src/main/docker/sonar.yml"); | ||
assertFileExist(project, "sonar-project.properties"); | ||
} | ||
|
||
public static void assertFrontProperties(Project project) { | ||
assertFileContent(project, "sonar-project.properties", "sonar.testExecutionReportPaths"); | ||
assertFileContent(project, "sonar-project.properties", "sonar.javascript.lcov.reportPaths"); | ||
} | ||
|
||
public static void assertPomXml(Project project) { | ||
assertFileContent(project, POM_XML, "<properties-maven-plugin.version>"); | ||
assertFileContent(project, POM_XML, "</properties-maven-plugin.version>"); | ||
assertFileContent(project, POM_XML, "<sonar-maven-plugin.version>"); | ||
assertFileContent(project, POM_XML, "</sonar-maven-plugin.version>"); | ||
|
||
assertFileContent(project, POM_XML, sonarSourcePlugin()); | ||
assertFileContent(project, POM_XML, propertiesPlugin()); | ||
} | ||
|
||
private static List<String> sonarSourcePlugin() { | ||
return List.of( | ||
"<plugin>", | ||
"<groupId>org.sonarsource.scanner.maven</groupId>", | ||
"<artifactId>sonar-maven-plugin</artifactId>", | ||
"<version>${sonar-maven-plugin.version}</version>", | ||
"</plugin>" | ||
); | ||
} | ||
|
||
private static List<String> propertiesPlugin() { | ||
return List.of( | ||
"<plugin>", | ||
"<groupId>org.codehaus.mojo</groupId>", | ||
"<artifactId>properties-maven-plugin</artifactId>", | ||
"<version>${properties-maven-plugin.version}</version>", | ||
"<executions>", | ||
"<execution>", | ||
"<phase>initialize</phase>", | ||
"<goals>", | ||
"<goal>read-project-properties</goal>", | ||
"</goals>", | ||
"<configuration>", | ||
"<files>", | ||
"<file>sonar-project.properties</file>", | ||
"</files>", | ||
"</configuration>", | ||
"</execution>", | ||
"</executions>", | ||
"</plugin>" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters