Skip to content

SONARPY-740 Rule S5756: Calls should not be made to non-callable values#782

Merged
guillaume-dequenne merged 2 commits intomasterfrom
SONARPY-740
Jun 11, 2020
Merged

SONARPY-740 Rule S5756: Calls should not be made to non-callable values#782
guillaume-dequenne merged 2 commits intomasterfrom
SONARPY-740

Conversation

@guillaume-dequenne
Copy link
Copy Markdown
Contributor

@guillaume-dequenne guillaume-dequenne commented Jun 11, 2020

Current implementation is missing secondary locations: they will be introduced through a new API based on flow sensitive type inference.

@guillaume-dequenne guillaume-dequenne force-pushed the SONARPY-740 branch 2 times, most recently from 7ea3955 to 4782cb2 Compare June 11, 2020 12:53
@guillaume-dequenne guillaume-dequenne marked this pull request as ready for review June 11, 2020 13:10
dict_var() # Noncompliant

set_var = set()
set_var() # FN (set has unresolved type hierarchy)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can hardcode it in the rule?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in aaaac0c. That said, I assume there will be many other types in that situation.

CallExpression callExpression = (CallExpression) ctx.syntaxNode();
Expression callee = callExpression.callee();
if (!callee.type().canHaveMember("__call__")) {
Optional<String> nameOptional = nameFromExpression(callee);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: I think I would prefer nameFromExpression to return null in this case

@sonarsource-next
Copy link
Copy Markdown

Kudos, SonarQube Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@guillaume-dequenne guillaume-dequenne merged commit 15d6524 into master Jun 11, 2020
@guillaume-dequenne guillaume-dequenne deleted the SONARPY-740 branch June 11, 2020 15:54
hashicorp-vault-sonar-prod Bot pushed a commit that referenced this pull request Jan 22, 2026
… to all network interfaces (#782)

GitOrigin-RevId: f9bd468fa03d1459f01f81425e6c0ecc2746f83a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants