opensnitch icon indicating copy to clipboard operation
opensnitch copied to clipboard

Convert five variable assignments to augmented source code

Open elfring opened this issue 4 years ago • 0 comments

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: 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 avatar Nov 22 '21 20:11 elfring