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 five variable assignments to augmented source code #549

Open
elfring opened this issue Nov 22, 2021 · 0 comments
Open

Convert five variable assignments to augmented source code #549

elfring opened this issue Nov 22, 2021 · 0 comments
Labels
feature a whole new feature

Comments

@elfring
Copy link

elfring commented Nov 22, 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/ui/opensnitch/database.py b/ui/opensnitch/database.py
index c4467fe..294b157 100644
--- a/ui/opensnitch/database.py
+++ b/ui/opensnitch/database.py
@@ -327,7 +327,7 @@ class Database:
     def delete_rule(self, name, node_addr):
         qstr = "DELETE FROM rules WHERE name=?"
         if node_addr != None:
-            qstr = qstr + " AND node=?"
+            qstr += " AND node=?"
 
         with self._lock:
             q = QSqlQuery(qstr, self.db)
@@ -345,7 +345,7 @@ class Database:
         """
         qstr = "SELECT * from rules WHERE name=?"
         if node_addr != None:
-            qstr = qstr + " AND node=?"
+            qstr += " AND node=?"
 
         q = QSqlQuery(qstr, self.db)
         q.prepare(qstr)
diff --git a/ui/opensnitch/dialogs/stats.py b/ui/opensnitch/dialogs/stats.py
index 6db559b..3ea4620 100644
--- a/ui/opensnitch/dialogs/stats.py
+++ b/ui/opensnitch/dialogs/stats.py
@@ -1291,8 +1291,8 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
             if what == "":
                 what = "WHERE"
             else:
-                what = what + " AND"
-            what = what + " r.name LIKE '%{0}%'".format(filter_text)
+                what += " AND"
+            what += " r.name LIKE '%{0}%'".format(filter_text)
         model = self._get_active_table().model()
         self.setQuery(model, "SELECT * FROM rules as r %s %s" % (what, self._get_order()))
 
diff --git a/utils/legacy/make_ads_rules.py b/utils/legacy/make_ads_rules.py
index 17ef929..8b86161 100644
--- a/utils/legacy/make_ads_rules.py
+++ b/utils/legacy/make_ads_rules.py
@@ -66,4 +66,4 @@ for domain, _ in domains.iteritems():
         data = tpl % ( now, now, idx, domain )
         fp.write(data)
 
-    idx = idx + 1
+    idx += 1
@elfring elfring added the feature a whole new feature label Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a whole new feature
Projects
None yet
Development

No branches or pull requests

1 participant