ruby-rdf/rdf

View on GitHub
lib/rdf/util/file.rb

Summary

Maintainability
D
1 day
Test Coverage

Method open_url has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def self.open_url(base_uri, proxy: nil, headers: {}, verify_none: false, **options)
        ssl_verify = verify_none ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER

        redirect_count = 0
        max_redirects = 5
Severity: Minor
Found in lib/rdf/util/file.rb - 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

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

      def initialize(body, options = {})
        options.each do |key, value|
          # de-quote charset
          matchdata = value.match(/^["'](.*)["']$/.freeze) if key == "charset"
          value = matchdata[1] if matchdata
Severity: Minor
Found in lib/rdf/util/file.rb - 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

Method open_url has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.open_url(base_uri, proxy: nil, headers: {}, verify_none: false, **options)
        ssl_verify = verify_none ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER

        redirect_count = 0
        max_redirects = 5
Severity: Minor
Found in lib/rdf/util/file.rb - About 1 hr to fix

    Method open_file has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.open_file(filename_or_url, proxy: nil, headers: {}, verify_none: false, **options, &block)
          filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
          remote_document = nil
    
          if filename_or_url.to_s.match?(/^https?/)
    Severity: Minor
    Found in lib/rdf/util/file.rb - About 1 hr to fix

      Method open_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.open_file(filename_or_url, proxy: nil, headers: {}, verify_none: false, **options, &block)
            filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
            remote_document = nil
      
            if filename_or_url.to_s.match?(/^https?/)
      Severity: Minor
      Found in lib/rdf/util/file.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 initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def initialize(body, options = {})
              options.each do |key, value|
                # de-quote charset
                matchdata = value.match(/^["'](.*)["']$/.freeze) if key == "charset"
                value = matchdata[1] if matchdata
      Severity: Minor
      Found in lib/rdf/util/file.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status