From 2b4195580353e75837c692c8df57e699bc06d455 Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Sun, 23 Jun 2024 07:48:49 -0700 Subject: [PATCH] Suggested small refactors in assignments (#1150) This change makes use of augmented assignment statements as suggested by issue #760. Fixes: #760` Signed-off-by: Eric Brown --- bandit/core/context.py | 2 +- bandit/formatters/xml.py | 2 +- bandit/plugins/injection_wildcard.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bandit/core/context.py b/bandit/core/context.py index 76b50923a..8a2d4fbbc 100644 --- a/bandit/core/context.py +++ b/bandit/core/context.py @@ -193,7 +193,7 @@ def _get_literal_value(self, literal): 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 6e196d92f..d2b2067ff 100644 --- a/bandit/formatters/xml.py +++ b/bandit/formatters/xml.py @@ -65,7 +65,7 @@ def report(manager, fileobj, sev_level, conf_level, lines=-1): "Test ID: %s Severity: %s Confidence: %s\nCWE: %s\n%s\n" "Location %s:%s" ) - text = text % ( + text %= ( issue.test_id, issue.severity, issue.confidence, diff --git a/bandit/plugins/injection_wildcard.py b/bandit/plugins/injection_wildcard.py index 94d03b30a..46f6b5b6c 100644 --- a/bandit/plugins/injection_wildcard.py +++ b/bandit/plugins/injection_wildcard.py @@ -124,7 +124,7 @@ def linux_commands_wildcard_injection(context, config): argument_string = "" if isinstance(call_argument, list): for li in call_argument: - argument_string = argument_string + f" {li}" + argument_string += f" {li}" elif isinstance(call_argument, str): argument_string = call_argument