marcus67/little_brother

View on GitHub

Showing 152 of 152 total issues

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

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

                def set_device_response_time(self, p_device_name, p_time):
        
                    self._gauge_device_response_time.labels(devicename=p_device_name).set(
                        p_time if p_time is not None else 0)
        Severity: Major
        Found in little_brother/prometheus.py and 1 other location - About 1 hr to fix
        little_brother/prometheus.py on lines 172..175

        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 39.

        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

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

                def set_device_moving_average_response_time(self, p_device_name, p_time):
        
                    self._gauge_device_moving_average_response_time.labels(devicename=p_device_name).set(
                        p_time if p_time is not None else 0)
        Severity: Major
        Found in little_brother/prometheus.py and 1 other location - About 1 hr to fix
        little_brother/prometheus.py on lines 163..166

        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 39.

        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

        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

          Function validate_context_details has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_context_details(self, p_context_detail):
          
                  if p_context_detail in WEEKPLAN_PREDEFINED_DETAILS:
                      return
          
          
          Severity: Minor
          Found in little_brother/simple_context_rule_handlers.py - About 55 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 7 locations. Consider refactoring.
          Open

                  with tools.TimingContext(lambda duration: self.measure(p_hostname=request.remote_addr,
                                                                         p_service=self.simplify_url(request.url_rule),
          Severity: Major
          Found in little_brother/web/login_view_handler.py and 6 other locations - About 55 mins to fix
          little_brother/web/about_view_handler.py on lines 48..49
          little_brother/web/admin_view_handler.py on lines 52..53
          little_brother/web/devices_view_handler.py on lines 90..91
          little_brother/web/status_view_handler.py on lines 51..52
          little_brother/web/topology_view_handler.py on lines 50..51
          little_brother/web/users_view_handler.py on lines 57..58

          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 37.

          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

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

                  with tools.TimingContext(lambda duration: self.measure(p_hostname=request.remote_addr,
                                                                         p_service=self.simplify_url(request.url_rule),
          Severity: Major
          Found in little_brother/web/admin_view_handler.py and 6 other locations - About 55 mins to fix
          little_brother/web/about_view_handler.py on lines 48..49
          little_brother/web/devices_view_handler.py on lines 90..91
          little_brother/web/login_view_handler.py on lines 42..43
          little_brother/web/status_view_handler.py on lines 51..52
          little_brother/web/topology_view_handler.py on lines 50..51
          little_brother/web/users_view_handler.py on lines 57..58

          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 37.

          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

          Function add_activity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_activity(self, p_activity):
          
                  self.activities.append(p_activity)
          
                  for host_stat in p_activity.host_stats.values():
          Severity: Minor
          Found in little_brother/process_statistics.py - About 55 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 check_min_break has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def check_min_break(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 55 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 7 locations. Consider refactoring.
          Open

                      with tools.TimingContext(lambda duration: self.measure(p_hostname=request.remote_addr,
                                                                             p_service=self.simplify_url(request.url_rule),
          Severity: Major
          Found in little_brother/web/users_view_handler.py and 6 other locations - About 55 mins to fix
          little_brother/web/about_view_handler.py on lines 48..49
          little_brother/web/admin_view_handler.py on lines 52..53
          little_brother/web/devices_view_handler.py on lines 90..91
          little_brother/web/login_view_handler.py on lines 42..43
          little_brother/web/status_view_handler.py on lines 51..52
          little_brother/web/topology_view_handler.py on lines 50..51

          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 37.

          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

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

                      with tools.TimingContext(lambda duration: self.measure(p_hostname=request.remote_addr,
                                                                             p_service=self.simplify_url(request.url_rule),
          Severity: Major
          Found in little_brother/web/devices_view_handler.py and 6 other locations - About 55 mins to fix
          little_brother/web/about_view_handler.py on lines 48..49
          little_brother/web/admin_view_handler.py on lines 52..53
          little_brother/web/login_view_handler.py on lines 42..43
          little_brother/web/status_view_handler.py on lines 51..52
          little_brother/web/topology_view_handler.py on lines 50..51
          little_brother/web/users_view_handler.py on lines 57..58

          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 37.

          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

          Severity
          Category
          Status
          Source
          Language