devices/linux/Files/main.py

Summary

Maintainability
F
6 days
Test Coverage

File main.py has 925 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
"""
 * **************************************************************************
 * Contributions to this work were made on behalf of the GÉANT project,
 * a project that has received funding from the European Union’s Framework
Severity: Major
Found in devices/linux/Files/main.py - About 2 days to fix

    Function prompt_nonempty_string has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        def prompt_nonempty_string(self, show: int, prompt: str, val: str = '') -> str:
            """
            Prompt user for input
            """
            if self.graphics == 'tty':
    Severity: Minor
    Found in devices/linux/Files/main.py - About 5 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 ask has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def ask(self, question: str, prompt: str = '', default: bool = None) -> int:
            """
            Prompt user for a Y/N reply, possibly supplying a default answer
            """
            if self.silent:
    Severity: Minor
    Found in devices/linux/Files/main.py - About 4 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 __process_p12 has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def __process_p12(self) -> bool:
            debug('process_p12')
            pfx_file = get_config_path() + '/cat_installer/user.p12'
            if CRYPTO_AVAILABLE:
                debug("using crypto")
    Severity: Minor
    Found in devices/linux/Files/main.py - About 3 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 __get_p12_cred has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __get_p12_cred(self):
            """get the password for the PFX file"""
            if Config.eap_inner == 'SILVERBULLET':
                self.__save_sb_pfx()
            else:
    Severity: Minor
    Found in devices/linux/Files/main.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 __select_p12_file has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __select_p12_file(self) -> str:
            """
            prompt user for the PFX file selection
            this method is not being called in the silent mode
            therefore there is no code for this case
    Severity: Minor
    Found in devices/linux/Files/main.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 __validate_user_name has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def __validate_user_name(self) -> bool:
            # locate the @ character in username
            pos = self.username.find('@')
            debug("@ position: " + str(pos))
            # trailing @
    Severity: Minor
    Found in devices/linux/Files/main.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 run_installer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_installer() -> None:
        """
        This is the main installer part. It tests for NM availability
        gets user credentials and starts a proper installer.
        """
    Severity: Minor
    Found in devices/linux/Files/main.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 __prepare_network_block has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __prepare_network_block(ssid: str, user_data: Type[InstallerData]) -> str:
            interface = """network={
            ssid=\"""" + ssid + """\"
            key_mgmt=WPA-EAP
            pairwise=CCMP
    Severity: Minor
    Found in devices/linux/Files/main.py - About 1 hr to fix

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

          def __get_username_password(self) -> None:
              """
              read user password and set the password property
              do nothing if silent mode is set
              """
      Severity: Minor
      Found in devices/linux/Files/main.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 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, silent: bool = False, username: str = '',
                       password: str = '', pfx_file: str = '') -> None:
              self.graphics = ''
              self.username = username
              self.password = password
      Severity: Minor
      Found in devices/linux/Files/main.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 detect_desktop_environment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def detect_desktop_environment() -> str:
          """
          Detect what desktop type is used. This method is prepared for
          possible future use with password encryption on supported distros
      
      
      Severity: Minor
      Found in devices/linux/Files/main.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 too many return statements within this function.
      Open

                  return False
      Severity: Major
      Found in devices/linux/Files/main.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                            return True
        Severity: Major
        Found in devices/linux/Files/main.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return 1
          Severity: Major
          Found in devices/linux/Files/main.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return True
            Severity: Major
            Found in devices/linux/Files/main.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return returncode
              Severity: Major
              Found in devices/linux/Files/main.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return True
                Severity: Major
                Found in devices/linux/Files/main.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return True
                  Severity: Major
                  Found in devices/linux/Files/main.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return False
                    Severity: Major
                    Found in devices/linux/Files/main.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return False
                      Severity: Major
                      Found in devices/linux/Files/main.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return False
                        Severity: Major
                        Found in devices/linux/Files/main.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return True
                          Severity: Major
                          Found in devices/linux/Files/main.py - About 30 mins to fix

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

                                def show_info(self, data: str) -> None:
                                    """
                                    Show a piece of information
                                    """
                                    if self.silent:
                            Severity: Minor
                            Found in devices/linux/Files/main.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 alert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def alert(self, text: str) -> None:
                                    """Generate alert message"""
                                    if self.silent:
                                        return
                                    if self.graphics == 'tty':
                            Severity: Minor
                            Found in devices/linux/Files/main.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_graphics_support has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def __get_graphics_support(self) -> None:
                                    if os.environ.get('DISPLAY') is not None:
                                        for cmd in ('zenity', 'kdialog', 'yad'):
                                            if self.__check_graphics(cmd):
                                                return
                            Severity: Minor
                            Found in devices/linux/Files/main.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

                            There are no issues that match your filters.

                            Category
                            Status