marcus67/little_brother

View on GitHub

Showing 111 of 152 total issues

Function get_current_active_pinfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_current_active_pinfo(self, p_hostname, p_username):

        max_start_time = None
        most_recent_pinfo = None

Severity: Minor
Found in little_brother/client_device_handler.py - About 35 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 build_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def build_url(self):

        if self._config.database_driver != persistence_base.DATABASE_DRIVER_SQLITE:
            if self._config.database_user is None:
                raise configuration.ConfigurationException("No database user configured!")
Severity: Minor
Found in little_brother/persistence/persistence.py - About 35 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 pick_text_for_ruleset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def pick_text_for_ruleset(self, p_rule_result_info):

        t = gettext.translation('messages', localedir=self._locale_dir,
                                languages=[p_rule_result_info.locale], fallback=True)

Severity: Minor
Found in little_brother/language.py - About 35 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 update_active_entries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def update_active_entries(self, p_ip_address: str, p_blocked_ip_addresses: List[str],
                              p_forward_entries: Dict[str, FirewallEntry], p_comment: str):

        # Use the devices blocked ip addresses if they defined else use the globally defined addresses
        effective_list_of_ip_addresses = self._config.target_ip \
Severity: Minor
Found in little_brother/devices/firewall_handler.py - About 35 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 request_time_extension has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def request_time_extension(self, p_session_context: SessionContext, p_user: User,
                               p_time_extension_length: int, p_reference_date: datetime.date=None):

        optional_time_available= self.get_optional_time_available_in_minutes(p_session_context=p_session_context,
                                                                             p_user=p_user, p_reference_date=p_reference_date)
Severity: Minor
Found in little_brother/api/api_view_handler.py - About 35 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 migrate_client_device_configs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def migrate_client_device_configs(self, p_client_device_configs, persistent_user2device=None):

        session = self._persistence.get_session()

        for device_name, old_device in p_client_device_configs.items():
Severity: Minor
Found in little_brother/db_migrations.py - About 35 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 get_user_status_infos has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_user_status_infos(self, p_session_context, p_process_infos, p_include_history=True):

        user_infos = {}

        reference_time = datetime.datetime.now()
Severity: Minor
Found in little_brother/admin_data_handler.py - About 35 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 format_text_array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def format_text_array(self, value):

        text = ""

        for part in value:
Severity: Minor
Found in little_brother/web/web_server.py - About 35 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 get_day_info_for_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_day_info_for_user(self, p_admin_info, p_username: str,
                              p_reference_date: datetime.datetime, p_rule_set) -> view_info.ViewInfo:

        if p_rule_set is not None:
            key_rule_override = rule_override.get_key(p_username=p_username,
Severity: Minor
Found in little_brother/admin_data_handler.py - About 35 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 save_for_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def save_for_user(self, p_forms, p_session_context, p_user):

        changed = False
        form = p_forms[p_user.html_key]
        a_persistent_user = self.user_entity_manager.get_by_username(
Severity: Minor
Found in little_brother/web/users_view_handler.py - About 35 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 too many return statements within this function.
Open

                    return self.invalid_secret_error()
Severity: Major
Found in little_brother/api/api_view_handler.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return ""
    Severity: Major
    Found in little_brother/language.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return t.gettext(self.text_need_break).format(**p_rule_result_info.args)
      Severity: Major
      Found in little_brother/language.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return t.gettext(self.text_min_break).format(**p_rule_result_info.args)
        Severity: Major
        Found in little_brother/language.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return ""
          Severity: Major
          Found in little_brother/language.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return self.wrong_parameter_format_error(p_parameter_name=constants.API_URL_PARAM_EXTENSION_LENGTH,
            Severity: Major
            Found in little_brother/api/api_view_handler.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return self.request_time_extension(p_session_context=session_context, p_user=user,
              Severity: Major
              Found in little_brother/api/api_view_handler.py - About 30 mins to fix

                Function get_current_rule_result_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_current_rule_result_info(self, p_reference_time, p_process_infos, p_username):
                
                        rule_result_info = None
                
                        with SessionContext(p_persistence=self.persistence) as session_context:
                Severity: Minor
                Found in little_brother/admin_data_handler.py - About 25 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_regex_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def process_regex_map(self):
                
                        with SessionContext(p_persistence=self.persistence) as session_context:
                            if self._process_regex_map is None:
                                self._process_regex_map = {}
                Severity: Minor
                Found in little_brother/process_handler_manager.py - About 25 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 get_optional_time_available_in_minutes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_optional_time_available_in_minutes(self, p_session_context: SessionContext, p_user: User,
                                                               p_reference_date: datetime.date=None):
                
                        if p_reference_date is None:
                            p_reference_date = datetime.date.today()
                Severity: Minor
                Found in little_brother/api/api_view_handler.py - About 25 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

                Severity
                Category
                Status
                Source
                Language