rapid7/metasploit-framework

View on GitHub
lib/rex/proto/kerberos/model/kdc_request_body.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class KdcRequestBody has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

        class KdcRequestBody < Element
          # @!attribute options
          #   @return [Integer] The ticket flags
          attr_accessor :options
          # @!attribute cname
Severity: Minor
Found in lib/rex/proto/kerberos/model/kdc_request_body.rb - About 3 hrs to fix

    Method encode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

              def encode
                elems = []
    
                elems << OpenSSL::ASN1::ASN1Data.new([encode_options], 0, :CONTEXT_SPECIFIC) if options
                elems << OpenSSL::ASN1::ASN1Data.new([encode_cname], 1, :CONTEXT_SPECIFIC) if cname
    Severity: Minor
    Found in lib/rex/proto/kerberos/model/kdc_request_body.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 decode_asn1 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

              def decode_asn1(input)
                seq_values = input.value
    
                seq_values.each do |val|
                  case val.tag
    Severity: Minor
    Found in lib/rex/proto/kerberos/model/kdc_request_body.rb - About 1 hr to fix

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

                def decode(input)
                  case input
                  when String
                    decode_string(input)
                  when OpenSSL::ASN1::Sequence
      Severity: Major
      Found in lib/rex/proto/kerberos/model/kdc_request_body.rb and 24 other locations - About 15 mins to fix
      lib/rex/proto/kerberos/model/ap_rep.rb on lines 25..35
      lib/rex/proto/kerberos/model/authenticator.rb on lines 47..57
      lib/rex/proto/kerberos/model/authorization_data.rb on lines 21..31
      lib/rex/proto/kerberos/model/checksum.rb on lines 22..32
      lib/rex/proto/kerberos/model/enc_ap_rep_part.rb on lines 32..42
      lib/rex/proto/kerberos/model/enc_kdc_response.rb on lines 75..85
      lib/rex/proto/kerberos/model/enc_krb_cred_part.rb on lines 19..29
      lib/rex/proto/kerberos/model/encrypted_data.rb on lines 30..40
      lib/rex/proto/kerberos/model/encryption_key.rb on lines 28..38
      lib/rex/proto/kerberos/model/host_address.rb on lines 23..33
      lib/rex/proto/kerberos/model/kdc_request.rb on lines 29..39
      lib/rex/proto/kerberos/model/kdc_response.rb on lines 37..47
      lib/rex/proto/kerberos/model/krb_cred.rb on lines 35..45
      lib/rex/proto/kerberos/model/krb_cred_info.rb on lines 66..76
      lib/rex/proto/kerberos/model/krb_error.rb on lines 55..65
      lib/rex/proto/kerberos/model/last_request.rb on lines 22..32
      lib/rex/proto/kerberos/model/pre_auth_etype_info2.rb on lines 20..30
      lib/rex/proto/kerberos/model/pre_auth_etype_info2_entry.rb on lines 26..36
      lib/rex/proto/kerberos/model/pre_auth_for_user.rb on lines 32..42
      lib/rex/proto/kerberos/model/pre_auth_pac_options.rb on lines 21..31
      lib/rex/proto/kerberos/model/principal_name.rb on lines 28..38
      lib/rex/proto/kerberos/model/ticket.rb on lines 35..45
      lib/rex/proto/kerberos/model/ticket_enc_part.rb on lines 26..36
      lib/rex/proto/kerberos/model/transited_encoding.rb on lines 19..29

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

      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

      There are no issues that match your filters.

      Category
      Status