Skip to content

Commit

Permalink
[NO JIRA] Fix Quality Flaws: S1854 Unused assignments should be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
alban-auzeill committed Oct 14, 2024
1 parent 39c1b0c commit fed5ece
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ void skippableVisitors_are_not_used_when_file_is_unchanged() throws ApiMismatchE
@Test
void scanWithoutParsing_returns_the_same_list_of_files_when_the_visitorsBridge_cannot_scan_without_parsing() {
SonarComponents sonarComponents = mock(SonarComponents.class);
CacheContext cacheContext = mock(CacheContext.class);
VisitorsBridge visitorsBridge = mock(VisitorsBridge.class);
doReturn(false).when(visitorsBridge).scanWithoutParsing(any());
JavaAstScanner javaAstScanner = new JavaAstScanner(sonarComponents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ void areVariablesSame_identifier_assert_false() {
void areVariablesSame_member_select_assert_true() {
var unit = JParserTestUtils.parse("class A { int min; void m(int min, int max, int value) { int conditionalValue = value == this.min ? min : value; }}");
var classTree = (ClassTree) unit.types().get(0);
var variable = (VariableTree) classTree.members().get(0);
var methodTree = (MethodTree) classTree.members().get(1);
var variableTree = (VariableTree) methodTree.block().body().get(0);
var initializer = (ConditionalExpressionTree) variableTree.initializer();
Expand All @@ -429,7 +428,6 @@ void areVariablesSame_member_select_assert_true() {
void areVariablesSame_member_select_assert_false() {
var unit = JParserTestUtils.parse("class A { int min; void m(int min, int max, int value) { int conditionalValue = value == this.min ? max : value; }}");
var classTree = (ClassTree) unit.types().get(0);
var variable = (VariableTree) classTree.members().get(0);
var methodTree = (MethodTree) classTree.members().get(1);
var variableTree = (VariableTree) methodTree.block().body().get(0);
var initializer = (ConditionalExpressionTree) variableTree.initializer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ void test() {

@Test
void invalid_file() {
Path uriRoot = Paths.get("");
Path p = Paths.get("file.class.smap");
assertThatThrownBy(() -> new SmapFile(p, "not a smap file", null, null))
.isInstanceOf(IllegalStateException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ void scanWithoutParsing_returns_false_when_the_file_cannot_be_skipped() throws A
VisitorsBridge visitorsBridge = new VisitorsBridge(null);
InputFile inputFile = mock(InputFile.class);
doReturn(InputFile.Status.CHANGED).when(inputFile).status();
CacheContext cacheContext = mock(CacheContext.class);
assertThat(visitorsBridge.scanWithoutParsing(inputFile)).isFalse();

// When SonarComponents is set and does not allow the file to be skipped
Expand All @@ -450,7 +449,7 @@ void scanWithoutParsing_returns_false_when_the_file_cannot_be_skipped() throws A
specificSonarComponents
);

assertThat(visitorsBridge.scanWithoutParsing(inputFile)).isFalse();
assertThat(visitorsBridgeWithSonarComponents.scanWithoutParsing(inputFile)).isFalse();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void transitive_as_name() {
assertThat(requires.directiveKeyword().text()).isEqualTo("requires");
// FIXME ECJ bug - transitive also counted as modifier
assertThat(requires.modifiers()).hasSize(1);
ModifierTree modifierTree = requires.modifiers().get(0);
assertThat(ModifiersUtils.hasModifier(requires.modifiers(), Modifier.TRANSITIVE)).isTrue();
assertThat(requires.moduleName().stream().map(IdentifierTree::name)).containsExactly("transitive");
assertThat(requires.semicolonToken().text()).isEqualTo(";");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public void before() {
void should_store_zero_tests_when_directory_is_null_or_non_existing_or_a_file() {

SensorContext context = mock(SensorContext.class);

context = mock(SensorContext.class);
parser.collect(context, getDirs("nonExistingReportsDirectory"), false);
verify(context, never()).newMeasure();

Expand Down

0 comments on commit fed5ece

Please sign in to comment.