yast/yast-registration

View on GitHub
src/lib/registration/connect_helpers.rb

Summary

Maintainability
C
1 day
Test Coverage

Method catch_registration_errors has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.catch_registration_errors(message_prefix: "",
      show_update_hint: false,
      silent_reg_code_mismatch: false,
      &block)
      # import the SSL certificate just once to avoid an infinite loop
Severity: Major
Found in src/lib/registration/connect_helpers.rb - About 3 hrs to fix

    Method handle_ssl_error has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.handle_ssl_error(error, certificate_imported)
          cert = Storage::SSLErrors.instance.ssl_failed_cert
          error_code = Storage::SSLErrors.instance.ssl_error_code
          expected_cert_type = Storage::Config.instance.reg_server_cert_fingerprint_type
    
    
    Severity: Minor
    Found in src/lib/registration/connect_helpers.rb - 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

    Method catch_registration_errors has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.catch_registration_errors(message_prefix: "",
          show_update_hint: false,
          silent_reg_code_mismatch: false,
          &block)
          # import the SSL certificate just once to avoid an infinite loop
    Severity: Minor
    Found in src/lib/registration/connect_helpers.rb - 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

    Method handle_ssl_error has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.handle_ssl_error(error, certificate_imported)
          cert = Storage::SSLErrors.instance.ssl_failed_cert
          error_code = Storage::SSLErrors.instance.ssl_error_code
          expected_cert_type = Storage::Config.instance.reg_server_cert_fingerprint_type
    
    
    Severity: Minor
    Found in src/lib/registration/connect_helpers.rb - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                return true if cert.import
      Severity: Major
      Found in src/lib/registration/connect_helpers.rb - About 45 mins to fix

        Method handle_network_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.handle_network_error(message_prefix, e)
              if Yast::NetworkService.isNetworkRunning
                # FIXME: use a better message, this one has been reused after the text freeze
                report_error(message_prefix + _("Invalid URL."), e.message)
              elsif Helpers.network_configurable && !Yast::Mode.auto
        Severity: Minor
        Found in src/lib/registration/connect_helpers.rb - 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