marcus67/little_brother

View on GitHub

Showing 111 of 152 total issues

Function get_process_statistics has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

def get_process_statistics(
        p_user_map,
        p_process_infos,
        p_reference_time,
        p_max_lookback_in_days,
Severity: Minor
Found in little_brother/process_statistics.py - About 7 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File app_control.py has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

# Copyright (C) 2019-2021  Marcus Rickert
#
# See https://github.com/marcus67/little_brother
Severity: Minor
Found in little_brother/app_control.py - About 6 hrs to fix

    Function prepare_services has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        def prepare_services(self, p_full_startup=True):
    
            super().prepare_services(p_full_startup=p_full_startup)
    
            # TODO: Activate in memory sqlite backend for clients
    Severity: Minor
    Found in little_brother/app.py - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function scan_processes has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def scan_processes(self, p_session_context, p_reference_time, p_server_group, p_login_mapping, p_host_name,
                           p_process_regex_map, p_prohibited_process_regex_map):
    
            events = []
    
    
    Severity: Minor
    Found in little_brother/client_device_handler.py - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    AppControl has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class AppControl(PersistenceDependencyInjectionMixIn):
    
        def __init__(self, p_config,
                     p_debug_mode,
                     p_process_handlers=None,
    Severity: Minor
    Found in little_brother/app_control.py - About 5 hrs to fix

      File app.py has 366 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      
      # Copyright (C) 2019-2022  Marcus Rickert
      #
      # See https://github.com/marcus67/little_brother
      Severity: Minor
      Found in little_brother/app.py - About 4 hrs to fix

        File process_handler_manager.py has 356 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        
        # Copyright (C) 2019-2021  Marcus Rickert
        #
        # See https://github.com/marcus67/little_brother
        Severity: Minor
        Found in little_brother/process_handler_manager.py - About 4 hrs to fix

          Function retrieve_user_mappings has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def retrieve_user_mappings(self, p_session_context: SessionContext):
          
                  if len(self._usernames_not_found) > 0:
                      usernames_found = []
          
          
          Severity: Minor
          Found in little_brother/user_manager.py - About 3 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function scan_processes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              def scan_processes(self, p_session_context, p_reference_time, p_server_group, p_login_mapping, p_host_name,
                                 p_process_regex_map, p_prohibited_process_regex_map):
          
                  current_processes = {}
                  events = []
          Severity: Minor
          Found in little_brother/client_process_handler.py - About 3 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          File rule_handler.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          
          # Copyright (C) 2019  Marcus Rickert
          #
          # See https://github.com/marcus67/little_brother
          Severity: Minor
          Found in little_brother/rule_handler.py - About 3 hrs to fix

            ProcessHandlerManager has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class ProcessHandlerManager(PersistenceDependencyInjectionMixIn):
            
                def __init__(self,
                             p_config,
                             p_is_master,
            Severity: Minor
            Found in little_brother/process_handler_manager.py - About 3 hrs to fix

              File process_statistics.py has 297 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # -*- coding: utf-8 -*-
              
              # Copyright (C) 2019  Marcus Rickert
              #
              # See https://github.com/marcus67/little_brother
              Severity: Minor
              Found in little_brother/process_statistics.py - About 3 hrs to fix

                Function set_metrics has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def set_metrics(self):
                
                        with SessionContext(p_persistence=self.persistence) as session_context:
                            if self.prometheus_client is not None:
                                self.prometheus_client.set_uptime(p_hostname="master", p_uptime=time.time() - self._start_time)
                Severity: Minor
                Found in little_brother/app_control.py - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function handle_rule_result_info has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def handle_rule_result_info(self, p_rule_result_info, p_stat_info, p_user):
                
                        if p_rule_result_info.activity_allowed():
                            self.check_issue_logout_warning(p_username=p_user.username, p_rule_result_info=p_rule_result_info)
                
                
                Severity: Minor
                Found in little_brother/process_handler_manager.py - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function process_rule_sets_for_all_users has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def process_rule_sets_for_all_users(self, p_reference_time):
                
                        fmt = "Processing rules for all users START..."
                        self._logger.debug(fmt)
                
                
                Severity: Minor
                Found in little_brother/app_control.py - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function migrate_ruleset_configs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def migrate_ruleset_configs(self, p_ruleset_configs):
                
                        session = self._persistence.get_session()
                
                        for username, configs in p_ruleset_configs.items():
                Severity: Minor
                Found in little_brother/db_migrations.py - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function check_device_activation_status has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def check_device_activation_status(self, p_force_usage_permitted=False):
                        with SessionContext(p_persistence=self.persistence) as session_context:
                            for device in self.device_entity_manager.devices(p_session_context=session_context):
                                usage_permitted = True
                                set_status = tools.is_valid_ip_address_or_dns_name(device.hostname)
                Severity: Minor
                Found in little_brother/devices/device_activation_manager.py - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function retrieve_version_infos has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def retrieve_version_infos(self):
                
                        if self._config.check_interval_in_days == 0:
                            return
                
                
                Severity: Minor
                Found in little_brother/api/version_checker.py - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                ApiViewHandler has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class ApiViewHandler(PersistenceDependencyInjectionMixIn):
                
                    def __init__(self, p_app):
                
                        super().__init__()
                Severity: Minor
                Found in little_brother/api/api_view_handler.py - About 2 hrs to fix

                  Function prepare_services has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def prepare_services(self, p_full_startup=True):
                  
                          super().prepare_services(p_full_startup=p_full_startup)
                  
                          # TODO: Activate in memory sqlite backend for clients
                  Severity: Minor
                  Found in little_brother/app.py - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language