ajenti / ajenti

if statements can be merged PTC-W0048
Anti-pattern
Major
6 months ago3 years old
Consider merging collapsible if statements
123            if 'Arch Linux' in release:
124                dist = 'arch'
125
126    if dist == '':127        if os.path.exists('/etc/system-release'):
128            release = open('/etc/system-release').read()
129            if 'Amazon Linux AMI' in release:
Consider merging collapsible if statements
117    else:
118        dist = pyplatform.dist()[0]
119
120    if dist == '':121        if os.path.exists('/etc/os-release'):
122            release = open('/etc/os-release').read()
123            if 'Arch Linux' in release:
Consider merging collapsible if statements
 41            context.identity = None
 42
 43    def handle(self, http_context):
 44        if http_context.env['SSL_CLIENT_VALID']: 45            if not self.context.identity:
 46                username = http_context.env['SSL_CLIENT_USER']
 47                logging.info(
Consider merging collapsible if statements
130                    self.q_socket_messages.broadcast(resp)
131                if resp.object['type'] == 'http':
132                    self.q_http_replies.broadcast(resp)
133                if resp.object['type'] == 'terminate':134                    if self.session != self.gateway_middleware:
135                        # Not the restricted session, we can disable it
136                        self.session.deactivate()
Consider merging collapsible if statements
 44
 45        for _dir in os.listdir(self.path):
 46            path = os.path.join(self.path, _dir)
 47            if os.path.isdir(path): 48                if os.path.exists(os.path.join(path, 'plugin.yml')):
 49                    found_plugins.append(path)
 50