digidentity/libsaml

View on GitHub

Showing 17 of 17 total issues

File saml.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'active_support/all'
require 'active_support/xml_mini'
require 'active_model'
require 'saml/base'
require 'saml/xml_helpers'
Severity: Minor
Found in lib/saml.rb - About 2 hrs to fix

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

        def to_xml(*args)
          options                              = args.extract_options!
          builder, default_namespace, instruct = args
          instruct                             = true if instruct.nil?
    
    
    Severity: Minor
    Found in lib/saml/xml_helpers.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 sign_xml has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def sign_xml(message, format = :xml, include_nested_prefixlist = false, &block)
            message.add_signature
    
            document = Xmldsig::SignedDocument.new(message.send("to_#{format}"))
    
    
    Severity: Minor
    Found in lib/saml/util.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_soap has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_soap(options = {})
          builder = Nokogiri::XML::Builder.new
          body    = self.to_xml(builder)
    
          builder = Nokogiri::XML::Builder.new(encoding: "UTF-8")
    Severity: Minor
    Found in lib/saml/xml_helpers.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 encrypt_assertion has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def encrypt_assertion(assertion, key_descriptor_or_certificate, include_certificate: false, include_key_retrieval_method: false)
            case key_descriptor_or_certificate
            when OpenSSL::X509::Certificate
              certificate = key_descriptor_or_certificate
              key_name    = nil
    Severity: Minor
    Found in lib/saml/util.rb - About 1 hr to fix

      Method encrypt_assertion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def encrypt_assertion(assertion, key_descriptor_or_certificate, include_certificate: false, include_key_retrieval_method: false)
              case key_descriptor_or_certificate
              when OpenSSL::X509::Certificate
                certificate = key_descriptor_or_certificate
                key_name    = nil
      Severity: Minor
      Found in lib/saml/util.rb - 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

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(metadata_dir = "config/metadata",
                           encryption_key_file = "config/ssl/key.pem", encryption_key_password = nil,
                           signing_key_file = nil, signing_key_password = nil)
      Severity: Minor
      Found in lib/saml/provider_stores/file.rb - About 35 mins to fix

        Method load_files has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def load_files(metadata_dir, encryption_key_file, encryption_key_password = nil,
                             sign_key_file = nil, sign_key_password = nil)
        Severity: Minor
        Found in lib/saml/provider_stores/file.rb - About 35 mins to fix

          Method x509certificate= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def x509certificate=(cert)
                    if cert.present?
                      if cert =~ /-----BEGIN CERTIFICATE-----/
                        @x509certificate = OpenSSL::X509::Certificate.new(cert)
                      else
          Severity: Minor
          Found in lib/saml/elements/key_info/x509_data.rb - 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

          Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(*args)
                options          = args.extract_options!
                if options[:subject].present?
                  @subject = options.delete(:subject)
                else
          Severity: Minor
          Found in lib/saml/assertion.rb - 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

          Method verify_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def verify_xml(message, raw_body)
                  document = Xmldsig::SignedDocument.new(raw_body)
          
                  signature_valid = document.validate do |signature, data, signature_algorithm|
                    node = document.signatures.find { |s| s.signature_value == signature }.signature.at_xpath('descendant::ds:KeyName', Xmldsig::NAMESPACES)
          Severity: Minor
          Found in lib/saml/util.rb - 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              def check_issue_instant
                errors.add(:issue_instant, :too_old) if issue_instant < Time.now - Saml::Config.max_issue_instant_offset.minutes
                errors.add(:issue_instant, :too_new) if issue_instant > Time.now + Saml::Config.max_issue_instant_offset.minutes
          Severity: Minor
          Found in lib/saml/assertion.rb and 1 other location - About 25 mins to fix
          lib/saml/complex_types/request_abstract_type.rb on lines 52..54

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

          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

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

              def verify(signature_algorithm, signature, data, key_name = nil)
                certificates = if key_name.blank? && iterate_certificates_until_verified?
                  find_key_descriptors_by_use_or_without('signing').collect(&:certificate)
                else
                  Array(certificate(key_name))
          Severity: Minor
          Found in lib/saml/provider.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

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

                def parse(xml, options = {})
                  if xml.is_a?(String)
                    ActiveSupport::XmlMini_REXML.parse(xml)
                  end
          
          
          Severity: Minor
          Found in lib/saml/base.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                def check_issue_instant
                  errors.add(:issue_instant, :too_old) if issue_instant < Time.now - Saml::Config.max_issue_instant_offset.minutes
                  errors.add(:issue_instant, :too_new) if issue_instant > Time.now + Saml::Config.max_issue_instant_offset.minutes
          Severity: Minor
          Found in lib/saml/complex_types/request_abstract_type.rb and 1 other location - About 25 mins to fix
          lib/saml/assertion.rb on lines 109..111

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

          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

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

            module Elements
              class Signature
                class SignatureMethod
                  include Saml::Base
          
          
          Severity: Minor
          Found in lib/saml/elements/signature/signature_method.rb and 1 other location - About 15 mins to fix
          lib/saml/elements/signature/digest_method.rb on lines 2..14

          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

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

            module Elements
              class Signature
                class DigestMethod
                  include Saml::Base
          
          
          Severity: Minor
          Found in lib/saml/elements/signature/digest_method.rb and 1 other location - About 15 mins to fix
          lib/saml/elements/signature/signature_method.rb on lines 2..14

          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

          Severity
          Category
          Status
          Source
          Language