marcus67/little_brother

View on GitHub

Showing 111 of 152 total issues

Function __init__ has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self,
                 p_config,
                 p_package_name,
                 p_app_control,
                 p_master_connector,
Severity: Minor
Found in little_brother/web/web_server.py - About 1 hr to fix

    Function devices_view has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def devices_view(self):
    
            with SessionContext(p_persistence=self.persistence) as session_context:
                request = flask.request
                with tools.TimingContext(lambda duration: self.measure(p_hostname=request.remote_addr,
    Severity: Minor
    Found in little_brother/web/devices_view_handler.py - About 1 hr 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 __init__ has 15 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, p_hostname=None,
    Severity: Major
    Found in little_brother/admin_event.py - About 1 hr to fix

      Function prepare_configuration has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def prepare_configuration(self, p_configuration: configuration.Configuration):
      
              app_control_section = AppControlConfigModel()
              p_configuration.add_section(app_control_section)
      
      
      Severity: Minor
      Found in little_brother/app.py - About 1 hr to fix

        Function handle_event_process_start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_event_process_start(self, p_event):
        
                process_handler = self.get_process_handler(p_id=p_event.processhandler)
        
                if process_handler is None:
        Severity: Minor
        Found in little_brother/process_handler_manager.py - About 1 hr 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 get_admin_info_for_user has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_admin_info_for_user(self, p_session_context, p_user_infos, p_time_extensions, p_days, p_username):
        
                user : User = self.user_entity_manager.user_map(p_session_context).get(p_username)
        
                if user is None or not user.active:
        Severity: Minor
        Found in little_brother/admin_data_handler.py - About 1 hr 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 apply_override has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def apply_override(p_rule_set, p_rule_override):
            rule_set = p_rule_set
        
            if p_rule_override is not None:
                rule_set = copy.copy(p_rule_set)
        Severity: Minor
        Found in little_brother/rule_result_info.py - About 1 hr 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_event_kill_process has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_event_kill_process(self, p_session_context: SessionContext, p_event,
                                          p_server_group: str = None, p_login_mapping: LoginMapping = None):
        
                fmt = "Kill process %d of user %s on host %s with signal SIGHUP" % (
                    p_event.pid, p_event.username, p_event.hostname)
        Severity: Minor
        Found in little_brother/client_process_handler.py - About 1 hr 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 get_users_forms has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_users_forms(self, p_session_context, p_users):
        
                forms = {}
        
                unmonitored_users = self.app_control.get_unmonitored_users(p_session_context)
        Severity: Minor
        Found in little_brother/web/users_view_handler.py - About 1 hr 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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, p_hostname=None, p_username=None, p_processhandler=None, p_processname=None, p_pid=None,
        Severity: Major
        Found in little_brother/process_info.py - About 1 hr to fix

          Function add_process_end has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_process_end(self, p_process_info, p_end_time):
          
                  # if the process is still running we store it as a candidate to be killed if required
                  if p_process_info.end_time is None:
                      process_list = self.currently_active_host_processes.get(p_process_info.hostname)
          Severity: Minor
          Found in little_brother/process_statistics.py - About 1 hr 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 __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, p_config, p_reuse_session=True):
          
                  self._logger = log_handling.get_logger(self.__class__.__name__)
                  self._config = p_config
                  self._session_used = False
          Severity: Minor
          Found in little_brother/persistence/persistence.py - About 1 hr 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_button_press_for_user has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle_button_press_for_user(self, p_forms, p_session_context, p_submit_id, p_user):
          
                  if p_submit_id == p_user.delete_html_key:
                      self.user_entity_manager.delete_user(
                          p_session_context=p_session_context, p_username=p_user.username)
          Severity: Minor
          Found in little_brother/web/users_view_handler.py - About 1 hr 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 __init__ has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def __init__(self, p_config,
                           p_debug_mode,
                           p_process_handlers=None,
                           p_device_handler=None,
                           p_notification_handlers=None,
          Severity: Minor
          Found in little_brother/app_control.py - About 1 hr to fix

            Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self,
            Severity: Major
            Found in little_brother/web/web_server.py - About 1 hr to fix

              Function load_historic_process_infos has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def load_historic_process_infos(self):
              
                      with SessionContext(p_persistence=self.persistence) as session_context:
                          pinfos = self.process_info_entity_manager.load_process_infos(
                              p_session_context=session_context, p_lookback_in_days=self._config.process_lookback_in_days + 1)
              Severity: Minor
              Found in little_brother/process_handler_manager.py - About 1 hr 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_migrations has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_migrations(self):
              
                      db_mig = db_migrations.DatabaseMigrations(p_logger=self._logger, p_persistence=self._persistence)
              
                      current_version = db_mig.get_current_version()
              Severity: Minor
              Found in little_brother/app.py - About 1 hr 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 read_from_configuration has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def read_from_configuration(self, p_session_context: SessionContext,
                                              p_login_mapping_section_handler: LoginMappingSectionHandler):
              
                      for section in p_login_mapping_section_handler._login_mapping_sections.values():
                          for mapping_entry in section.mapping_entries:
              Severity: Minor
              Found in little_brother/login_mapping.py - About 1 hr 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_time_per_day has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_time_per_day(self, p_rule_set: RuleSetConfigModel, p_stat_info: process_statistics.ProcessStatisticsInfo,
                                         p_rule_result_info: RuleResultInfo):
              
                      if p_rule_result_info.skip_negative_checks():
                          # shortcut because granting playtime has higher priority
              Severity: Minor
              Found in little_brother/rule_handler.py - About 1 hr 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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, p_username, p_reference_date, p_max_time_per_day=None,
              Severity: Major
              Found in little_brother/rule_override.py - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language