]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
sonarlink: use opposite operator != instead of 'not'
authorJulien Fortin <jfortin@nvidia.com>
Tue, 14 Feb 2023 12:32:57 +0000 (13:32 +0100)
committerJulien Fortin <jfortin@nvidia.com>
Thu, 4 May 2023 11:21:55 +0000 (13:21 +0200)
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
ifupdown2/addons/address.py
ifupdown2/addons/addressvirtual.py
ifupdown2/addons/dhcp.py
ifupdown2/addons/vlan.py
ifupdown2/addons/vxlan.py
ifupdown2/ifupdown/ifupdownmain.py
ifupdown2/ifupdown/main.py

index 54704bde2a055adee6e68bcba71780a0586abbcd..ac88a5e37a7643d6283f1fe8ec6d249bebe3f7cb 100644 (file)
@@ -848,7 +848,7 @@ class address(AddonWithIpBlackList, moduleBase):
                     self.sysfs.link_set_mtu(ifaceobj.name, mtu_str=str(lower_iface_mtu_int), mtu_int=lower_iface_mtu_int)
 
         elif (
-            not (ifaceobj.name == 'lo')
+            ifaceobj.name != 'lo'
             and not ifaceobj.link_kind
             and not (ifaceobj.link_privflags & ifaceLinkPrivFlags.BOND_SLAVE)
             and self.default_mtu
index 71ade4fb30d426329ab1ed59a67e870ce699681e..0cd9c737eb8854e4e516878820122b3ca878c338 100644 (file)
@@ -286,7 +286,7 @@ class addressvirtual(AddonWithIpBlackList, moduleBase):
         ]:
             for macvlan_ifacename in glob.glob("/sys/class/net/%s*" % macvlan_prefix):
                 macvlan_ifacename = os.path.basename(macvlan_ifacename)
-                if not self.cache.link_exists(macvlan_ifacename) or not self.cache.get_link_kind(macvlan_ifacename) == "macvlan":
+                if not self.cache.link_exists(macvlan_ifacename) or self.cache.get_link_kind(macvlan_ifacename) != "macvlan":
                     continue
                 hwaddress.append(self.cache.get_link_address(macvlan_ifacename))
                 self.netlink.link_del(os.path.basename(macvlan_ifacename))
index 1b3d7005ac4b466262e7f66613e4214c7a72bec1..4d1da1a483d988dc8c1943de7a32db121f34f900 100644 (file)
@@ -149,7 +149,7 @@ class dhcp(Addon, moduleBase):
             dhclient_cmd_prefix = None
             dhcp_wait = policymanager.policymanager_api.get_attr_default(
                 module_name=self.__class__.__name__, attr='dhcp-wait')
-            wait = not str(dhcp_wait).lower() == "no"
+            wait = str(dhcp_wait).lower() != "no"
             dhcp6_ll_wait = policymanager.policymanager_api.get_iface_default(module_name=self.__class__.__name__, \
                 ifname=ifaceobj.name, attr='dhcp6-ll-wait')
             try:
index 72291fdc547c4f20899df72f5bae7d92e6e85932..06e87bbed0a763c75985018e0e85e11b9d9cdce7 100644 (file)
@@ -297,7 +297,7 @@ class vlan(Addon, moduleBase):
         if not self.cache.link_exists(ifname):
             return
 
-        if not self.cache.get_link_kind(ifname) == 'vlan':
+        if self.cache.get_link_kind(ifname) != 'vlan':
             return
 
         # If vlan name is not in the dot format, get the
index 012aba4dc7b2950afc6134d877f434b22f780941..11cc75edeadd7b6f8447b0722f97e99cf393549e 100644 (file)
@@ -1650,7 +1650,7 @@ class vxlan(Vxlan, moduleBase):
         if not self.cache.link_exists(ifname):
             return
 
-        if not self.cache.get_link_kind(ifname) == 'vxlan':
+        if self.cache.get_link_kind(ifname) != 'vxlan':
             return
 
         cached_vxlan_ifla_info_data = self.cache.get_link_info_data(ifname)
index f00154334bf5a0a0b2aca1419e02c7b0219a9c69..9b787ed3a009f87f0e7133f86035d9c0b16824d2 100644 (file)
@@ -1121,7 +1121,7 @@ class ifupdownMain:
                                                    '-'.join(validrange)))
 
                     if multiple is not None:
-                        if not (n % multiple == 0):
+                        if n % multiple != 0:
                             raise invalidValueError('invalid value %s: must be a multiple of %s' % (n, multiple))
 
                     return True
@@ -1147,7 +1147,7 @@ class ifupdownMain:
                            '-'.join(validrange)))
 
                 if multiple is not None:
-                    if not (number % multiple == 0):
+                    if number % multiple != 0:
                         raise invalidValueError('invalid value %s: must be a multiple of %s' % (number, multiple))
 
             return True
index 5ab07fa8d7e003a350499112ba9e1d41d1dec047..903c477763922ec4920944cb7dc883826c2fee37 100644 (file)
@@ -113,7 +113,7 @@ class Ifupdown2:
         if hasattr(self.args, 'interfacesfile') and self.args.interfacesfile != None:
             # Check to see if -i option is allowed by config file
             # But for ifquery, we will not check this
-            if (not self.op == 'query' and
+            if (self.op != 'query' and
                         configmap_g.get('disable_cli_interfacesfile', '0') == '1'):
                 log.error('disable_cli_interfacesfile is set so users '
                           'not allowed to specify interfaces file on cli.')