marcus67/little_brother

View on GitHub

Showing 152 of 152 total issues

Function process_queue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def process_queue(self):

        while self._event_queue.qsize() > 0:
            try:
                event = self._event_queue.get(block=False)
Severity: Minor
Found in little_brother/event_handler.py - About 45 mins 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_user has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def process_rule_sets_for_user(self, p_rule_sets, p_stat_info, p_active_time_extension,
Severity: Minor
Found in little_brother/rule_handler.py - About 45 mins to fix

    Function get_client_stats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_client_stats(self):
    
            a_client_stats = client_stats.ClientStats(
                p_version=self.get_client_version(),
                p_revision=settings.extended_settings['debian_package_revision'],
    Severity: Minor
    Found in little_brother/app_control.py - About 45 mins 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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                        if current_pinfo is not None:
                            event = self.create_admin_event_process_end_from_pinfo(
                                p_pinfo=current_pinfo,
                                p_reference_time=p_reference_time)
                            events.append(event)
    Severity: Minor
    Found in little_brother/client_device_handler.py and 1 other location - About 45 mins to fix
    little_brother/client_device_handler.py on lines 306..323

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 35.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Avoid deeply nested control flow statements.
    Open

                            if not self._login_mapping_received:
                                self._logger.warn(f"Setting local mapping entry for user {username}")
                            self._login_mapping.add_entry(p_session_context=p_session_context,
    Severity: Major
    Found in little_brother/user_manager.py - About 45 mins to fix

      Function check_activity_duration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_activity_duration(self, p_rule_set: RuleSetConfigModel,
                                      p_stat_info: process_statistics.ProcessStatisticsInfo,
                                      p_rule_result_info: RuleResultInfo):
      
              if p_rule_result_info.skip_negative_checks():
      Severity: Minor
      Found in little_brother/rule_handler.py - About 45 mins 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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

                          if user2device.active:
                              if current_pinfo is None:
                                  event = admin_event.AdminEvent(
                                      p_event_type=admin_event.EVENT_TYPE_PROCESS_START,
                                      p_hostname=device_info.hostname,
      Severity: Minor
      Found in little_brother/client_device_handler.py and 1 other location - About 45 mins to fix
      little_brother/client_device_handler.py on lines 332..336

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Avoid deeply nested control flow statements.
      Open

                              if stat_info is not None:
                                  self._logger.debug(str(stat_info))
      
                                  key_rule_override = rule_override.get_key(p_username=user.username,
                                                                            p_reference_date=p_reference_time.date())
      Severity: Major
      Found in little_brother/app_control.py - About 45 mins to fix

        Function check_vacation_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_vacation_data(self):
        
                if self._vacation_data is None:
                    url = self._config.vacation_data_url
                    request = requests.get(url)
        Severity: Minor
        Found in little_brother/german_vacation_context_rule_handler.py - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                            for i in range(len(user_stat_info.day_statistics), lookback + 1):
                                user_stat_info.day_statistics.append(DayStatistics())
        
        
        Severity: Major
        Found in little_brother/process_statistics.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not unix_user_handler_config.is_active():
                                      unix_user_handler_config.admin_username = status_server_config.admin_username
                                      unix_user_handler_config.admin_password = status_server_config.admin_password
          
          
          Severity: Major
          Found in little_brother/app.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        for device in devices:
                                            if request.form['submit'] == device.delete_html_key:
                                                self.device_entity_manager.delete_device(
                                                    p_session_context=session_context, p_id=device.id)
            
            
            Severity: Major
            Found in little_brother/web/devices_view_handler.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if self.prometheus_client is not None:
                                          self.prometheus_client.count_forced_logouts(p_username=p_user.username)
              
              
              Severity: Major
              Found in little_brother/process_handler_manager.py - About 45 mins to fix

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

                    def __init__(self, p_version=None, p_revision=None, p_python_version=None,
                Severity: Minor
                Found in little_brother/client_stats.py - About 45 mins to fix

                  Function queue_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def queue_event(self, p_event, p_to_master=False, p_is_action=False):
                  
                          if p_is_action:
                              if p_event.hostname == self._host_name:
                                  self.queue_event_locally(p_event=p_event)
                  Severity: Minor
                  Found in little_brother/event_handler.py - About 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self, p_username, p_reference_time, p_max_lookback_in_days, p_min_activity_duration,
                  Severity: Minor
                  Found in little_brother/process_statistics.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if (pinfo.processname is None or
                                                (pinfo.processname is not None and user.regex_process_name_pattern.match(
                                                    pinfo.processname))):
                                            stat_info = user_stat_infos.get(ruleset.context)
                    
                    
                    Severity: Major
                    Found in little_brother/process_statistics.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if pinfo.end_time is not None:
                                                      event = self.create_admin_event_process_start_from_pinfo(p_pinfo=pinfo)
                                                      events.append(event)
                      
                      
                      Severity: Major
                      Found in little_brother/client_process_handler.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if current_pinfo is not None:
                                                    event = self.create_admin_event_process_end_from_pinfo(
                                                        p_pinfo=current_pinfo,
                                                        p_reference_time=p_reference_time)
                                                    events.append(event)
                        Severity: Major
                        Found in little_brother/client_device_handler.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if current_pinfo is None:
                                                      event = admin_event.AdminEvent(
                                                          p_event_type=admin_event.EVENT_TYPE_PROCESS_START,
                                                          p_hostname=device_info.hostname,
                                                          p_hostlabel=device_info.device_name,
                          Severity: Major
                          Found in little_brother/client_device_handler.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language