hirura/hrr_rb_ssh-ed25519

View on GitHub

Showing 3 of 3 total issues

Method load_openssl_key has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

          def load_openssl_key key_str
            private_key_begin_marker = "-----BEGIN PRIVATE KEY-----\n"
            public_key_begin_marker  = "-----BEGIN PUBLIC KEY-----\n"
            if key_str.start_with? private_key_begin_marker
              begin_marker = "-----BEGIN PRIVATE KEY-----\n"
Severity: Minor
Found in lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb - 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

Method to_pem has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def to_pem
            ed25519_object_id = '1.3.101.112'
            case @key
=begin
            when ::Ed25519::SigningKey
Severity: Minor
Found in lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb - About 1 hr to fix

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

              def load_openssh_key key_str
                begin_marker = "-----BEGIN OPENSSH PRIVATE KEY-----\n"
                end_marker   = "-----END OPENSSH PRIVATE KEY-----\n"
                magic        = "openssh-key-v1"
    
    
    Severity: Minor
    Found in lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.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

    Severity
    Category
    Status
    Source
    Language