Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONARPY-2345 Document new S1172 FN when super class is ambiguous #2164

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ void test() {
@Test
void test_import() {
PythonCheckVerifier.verify(
List.of("src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImport.py","src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImported.py"),
List.of(
"src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImport.py",
"src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImported.py"
),
new UnusedFunctionParameterCheck()
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from unusedFunctionParameterImported import ImportedParent
from unusedFunctionParameterImported import ImportedParent, ParentWithDuplicatedParent

class ChildFromImported(ImportedParent):

# SONARPY-2327 `method_defined_in_child_class_only` is not considered a member of ImportedParent class, thus S1172 is raised
# SONARPY-1829 `method_defined_in_child_class_only` is not considered a member of ImportedParent class, thus S1172 is raised
def method_defined_in_child_class_only(self, a): # Noncompliant
# ^
return compute()

def method_defined_in_child_class_only_and_not_used(self, a): # Noncompliant
# ^
return compute()

class ChildFromDuplicated(ParentWithDuplicatedParent):

def do_something(self, a): # FN SONARPY-1829 ChildFromDuplicated has an unresolved type hierarchy, because of the duplicated parent classes
return compute()

Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
class ImportedParent:
def using_child_method(self):
return self.method_defined_in_child_class_only(1,2)

class DuplicatedParent:
...

class DuplicatedParent:
...

class ParentWithDuplicatedParent(DuplicatedParent):
...