diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2021-11-18 16:45:02 -0600 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-11-20 20:03:51 +0000 |
commit | 3f9445c25962f914ccdd889c002ddd8e19b0cf89 (patch) | |
tree | eb4f34a62b7164a71fd0bbe34d6f59621a687d8d /sonar-scanner-protocol | |
parent | aa640be9e2b9cfa2c027ef0768940b31ebb5536c (diff) | |
download | sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.tar.gz sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.zip |
Improve code quality
Diffstat (limited to 'sonar-scanner-protocol')
3 files changed, 17 insertions, 20 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java index dbf4ac818f0..6d6f3a77051 100644 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java @@ -655,8 +655,7 @@ public class ScannerReportViewerApp { * @wbp.factory */ public static JPanel createComponentPanel() { - JPanel panel = new JPanel(); - return panel; + return new JPanel(); } protected JEditorPane getComponentEditor() { @@ -667,15 +666,13 @@ public class ScannerReportViewerApp { * @wbp.factory */ public static JEditorPane createSourceEditor() { - JEditorPane editorPane = new JEditorPane(); - return editorPane; + return new JEditorPane(); } /** * @wbp.factory */ public TextLineNumber createTextLineNumber() { - TextLineNumber textLineNumber = new TextLineNumber(sourceEditor); - return textLineNumber; + return new TextLineNumber(sourceEditor); } } diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java index 3b29d521224..3bd3cb8e3a9 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java @@ -67,7 +67,7 @@ public class ScannerReportReaderTest { ScannerReport.Metadata readMetadata = underTest.readMetadata(); assertThat(readMetadata.getAnalysisDate()).isEqualTo(15000000L); assertThat(readMetadata.getProjectKey()).isEqualTo("PROJECT_A"); - assertThat(readMetadata.getRootComponentRef()).isEqualTo(1); + assertThat(readMetadata.getRootComponentRef()).isOne(); assertThat(readMetadata.getCrossProjectDuplicationActivated()).isTrue(); } @@ -230,7 +230,7 @@ public class ScannerReportReaderTest { try (CloseableIterator<ScannerReport.SyntaxHighlightingRule> it = underTest.readComponentSyntaxHighlighting(1)) { ScannerReport.SyntaxHighlightingRule syntaxHighlighting = it.next(); assertThat(syntaxHighlighting.getRange()).isNotNull(); - assertThat(syntaxHighlighting.getRange().getStartLine()).isEqualTo(1); + assertThat(syntaxHighlighting.getRange().getStartLine()).isOne(); assertThat(syntaxHighlighting.getRange().getEndLine()).isEqualTo(10); assertThat(syntaxHighlighting.getType()).isEqualTo(HighlightingType.ANNOTATION); } @@ -300,10 +300,10 @@ public class ScannerReportReaderTest { underTest = new ScannerReportReader(dir); try (CloseableIterator<ScannerReport.LineCoverage> it = new ScannerReportReader(dir).readComponentCoverage(1)) { ScannerReport.LineCoverage coverage = it.next(); - assertThat(coverage.getLine()).isEqualTo(1); - assertThat(coverage.getConditions()).isEqualTo(1); + assertThat(coverage.getLine()).isOne(); + assertThat(coverage.getConditions()).isOne(); assertThat(coverage.getHits()).isTrue(); - assertThat(coverage.getCoveredConditions()).isEqualTo(1); + assertThat(coverage.getCoveredConditions()).isOne(); } } diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java index 42b4df67ab7..045d18f8514 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java @@ -68,7 +68,7 @@ public class ScannerReportWriterTest { ScannerReport.Metadata read = Protobuf.read(underTest.getFileStructure().metadataFile(), ScannerReport.Metadata.parser()); assertThat(read.getAnalysisDate()).isEqualTo(15000000L); assertThat(read.getProjectKey()).isEqualTo("PROJECT_A"); - assertThat(read.getRootComponentRef()).isEqualTo(1); + assertThat(read.getRootComponentRef()).isOne(); } @Test @@ -91,7 +91,7 @@ public class ScannerReportWriterTest { File file = underTest.getFileStructure().fileFor(FileStructure.Domain.COMPONENT, 1); assertThat(file).exists().isFile(); ScannerReport.Component read = Protobuf.read(file, ScannerReport.Component.parser()); - assertThat(read.getRef()).isEqualTo(1); + assertThat(read.getRef()).isOne(); assertThat(read.getChildRefList()).containsOnly(5, 42); assertThat(read.getName()).isEmpty(); assertThat(read.getIsTest()).isFalse(); @@ -113,7 +113,7 @@ public class ScannerReportWriterTest { File file = underTest.getFileStructure().fileFor(FileStructure.Domain.ISSUES, 1); assertThat(file).exists().isFile(); try (CloseableIterator<ScannerReport.Issue> read = Protobuf.readStream(file, ScannerReport.Issue.parser())) { - assertThat(Iterators.size(read)).isEqualTo(1); + assertThat(Iterators.size(read)).isOne(); } } @@ -133,7 +133,7 @@ public class ScannerReportWriterTest { File file = underTest.getFileStructure().fileFor(FileStructure.Domain.EXTERNAL_ISSUES, 1); assertThat(file).exists().isFile(); try (CloseableIterator<ScannerReport.ExternalIssue> read = Protobuf.readStream(file, ScannerReport.ExternalIssue.parser())) { - assertThat(Iterators.size(read)).isEqualTo(1); + assertThat(Iterators.size(read)).isOne(); } } @@ -154,7 +154,7 @@ public class ScannerReportWriterTest { File file = underTest.getFileStructure().adHocRules(); assertThat(file).exists().isFile(); try (CloseableIterator<ScannerReport.AdHocRule> read = Protobuf.readStream(file, ScannerReport.AdHocRule.parser())) { - assertThat(Iterators.size(read)).isEqualTo(1); + assertThat(Iterators.size(read)).isOne(); } } @@ -189,7 +189,7 @@ public class ScannerReportWriterTest { File file = underTest.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1); assertThat(file).exists().isFile(); try (CloseableIterator<ScannerReport.Measure> read = Protobuf.readStream(file, ScannerReport.Measure.parser())) { - assertThat(Iterators.size(read)).isEqualTo(1); + assertThat(Iterators.size(read)).isOne(); } } @@ -212,8 +212,8 @@ public class ScannerReportWriterTest { File file = underTest.getFileStructure().fileFor(FileStructure.Domain.CHANGESETS, 1); assertThat(file).exists().isFile(); ScannerReport.Changesets read = Protobuf.read(file, ScannerReport.Changesets.parser()); - assertThat(read.getComponentRef()).isEqualTo(1); - assertThat(read.getChangesetCount()).isEqualTo(1); + assertThat(read.getComponentRef()).isOne(); + assertThat(read.getChangesetCount()).isOne(); assertThat(read.getChangesetList()).hasSize(1); assertThat(read.getChangeset(0).getDate()).isEqualTo(123_456_789L); } @@ -266,7 +266,7 @@ public class ScannerReportWriterTest { try (CloseableIterator<ScannerReport.CpdTextBlock> duplicationBlocks = Protobuf.readStream(file, ScannerReport.CpdTextBlock.parser())) { ScannerReport.CpdTextBlock duplicationBlockResult = duplicationBlocks.next(); assertThat(duplicationBlockResult.getHash()).isEqualTo("abcdefghijklmnop"); - assertThat(duplicationBlockResult.getStartLine()).isEqualTo(1); + assertThat(duplicationBlockResult.getStartLine()).isOne(); assertThat(duplicationBlockResult.getEndLine()).isEqualTo(2); assertThat(duplicationBlockResult.getStartTokenIndex()).isEqualTo(10); assertThat(duplicationBlockResult.getEndTokenIndex()).isEqualTo(15); |