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

Convert three assignments to augmented source code #760

Closed
elfring opened this issue Nov 21, 2021 · 0 comments · Fixed by #1150
Closed

Convert three assignments to augmented source code #760

elfring opened this issue Nov 21, 2021 · 0 comments · Fixed by #1150
Labels
enhancement New feature or request

Comments

@elfring
Copy link

elfring commented Nov 21, 2021

👀 Some source code analysis tools can help to find opportunities for improving software components.
💭 I propose to increase the usage of augmented assignment statements accordingly.

diff --git a/bandit/core/context.py b/bandit/core/context.py
index 139deb5..8b2fe26 100644
--- a/bandit/core/context.py
+++ b/bandit/core/context.py
@@ -190,7 +190,7 @@ class Context(object):
         elif isinstance(literal, ast.Tuple):
             return_tuple = tuple()
             for ti in literal.elts:
-                return_tuple = return_tuple + (self._get_literal_value(ti),)
+                return_tuple += (self._get_literal_value(ti),)
             literal_value = return_tuple
 
         elif isinstance(literal, ast.Set):
diff --git a/bandit/formatters/xml.py b/bandit/formatters/xml.py
index 5225715..1b53853 100644
--- a/bandit/formatters/xml.py
+++ b/bandit/formatters/xml.py
@@ -59,7 +59,7 @@ def report(manager, fileobj, sev_level, conf_level, lines=-1):
                                  classname=issue.fname, name=test)
 
         text = 'Test ID: %s Severity: %s Confidence: %s\n%s\nLocation %s:%s'
-        text = text % (issue.test_id, issue.severity, issue.confidence,
+        text %= (issue.test_id, issue.severity, issue.confidence,
                        issue.text, issue.fname, issue.lineno)
         ET.SubElement(testcase, 'error',
                       more_info=docs_utils.get_url(issue.test_id),
diff --git a/bandit/plugins/injection_wildcard.py b/bandit/plugins/injection_wildcard.py
index 0988129..66386db 100644
--- a/bandit/plugins/injection_wildcard.py
+++ b/bandit/plugins/injection_wildcard.py
@@ -120,7 +120,7 @@ def linux_commands_wildcard_injection(context, config):
             argument_string = ''
             if isinstance(call_argument, list):
                 for li in call_argument:
-                    argument_string = argument_string + ' %s' % li
+                    argument_string += ' %s' % li
             elif isinstance(call_argument, str):
                 argument_string = call_argument
 
@elfring elfring added the enhancement New feature or request label Nov 21, 2021
ericwb added a commit to ericwb/bandit that referenced this issue Jun 23, 2024
This change makes use of augmented assignment statements as suggested
by issue PyCQA#760.

Fixes: PyCQA#760`

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
ericwb added a commit that referenced this issue Jun 23, 2024
This change makes use of augmented assignment statements as suggested
by issue #760.

Fixes: #760`

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant