marcus67/little_brother

View on GitHub

Showing 152 of 152 total issues

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

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

        def get_text_unlimited_session_start(self, p_locale, p_variables):
    
            t = gettext.translation('messages', localedir=self._locale_dir,
                                    languages=[p_locale], fallback=True)
            return t.gettext(self.text_unlimited_session_start).format(**p_variables)
    Severity: Major
    Found in little_brother/language.py and 2 other locations - About 2 hrs to fix
    little_brother/language.py on lines 59..63
    little_brother/language.py on lines 71..75

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

    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 3 locations. Consider refactoring.
    Open

        def get_text_prohibited_process(self, p_locale, p_variables):
    
            t = gettext.translation('messages', localedir=self._locale_dir,
                                    languages=[p_locale], fallback=True)
            return t.gettext(self.text_prohibited_process).format(**p_variables)
    Severity: Major
    Found in little_brother/language.py and 2 other locations - About 2 hrs to fix
    little_brother/language.py on lines 59..63
    little_brother/language.py on lines 65..69

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

    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 3 locations. Consider refactoring.
    Open

        def get_text_limited_session_start(self, p_locale, p_variables):
    
            t = gettext.translation('messages', localedir=self._locale_dir,
                                    languages=[p_locale], fallback=True)
            return t.gettext(self.text_limited_session_start).format(**p_variables)
    Severity: Major
    Found in little_brother/language.py and 2 other locations - About 2 hrs to fix
    little_brother/language.py on lines 65..69
    little_brother/language.py on lines 71..75

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

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

      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

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

                def update_sample_size(self, p_sample_size):
            
                    if self._sample_size is not None and p_sample_size != self._sample_size:
                        self.clear_moving_average()
            
            
            Severity: Major
            Found in little_brother/client_device_handler.py and 1 other location - About 1 hr to fix
            little_brother/client_device_handler.py on lines 113..118

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

            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 update_hostname(self, p_hostname):
            
                    if self._hostname is not None and p_hostname != self._hostname:
                        self.clear_moving_average()
            
            
            Severity: Major
            Found in little_brother/client_device_handler.py and 1 other location - About 1 hr to fix
            little_brother/client_device_handler.py on lines 128..133

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

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

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

                    for user2device in p_user.devices:
                        form = p_forms[user2device.html_key]
            
                        if self.save_for_user2device(p_form=form, p_session_context=p_session_context, p_user2device=user2device):
                            changed = True
            Severity: Major
            Found in little_brother/web/users_view_handler.py and 1 other location - About 1 hr to fix
            little_brother/web/users_view_handler.py on lines 274..278

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

            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

                    for rule_set in p_user.rulesets:
                        form = p_forms[rule_set.html_key]
            
                        if self.save_for_rule_set(p_form=form, p_session_context=p_session_context, p_rule_set=rule_set):
                            changed = True
            Severity: Major
            Found in little_brother/web/users_view_handler.py and 1 other location - About 1 hr to fix
            little_brother/web/users_view_handler.py on lines 280..284

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

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

            Severity
            Category
            Status
            Source
            Language