ruby-rdf/rdf

View on GitHub
lib/rdf/ntriples/reader.rb

Summary

Maintainability
C
1 day
Test Coverage

Method read_literal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def read_literal
      if literal_str = match(LITERAL_PLAIN)
        literal_str = self.class.unescape(literal_str)
        literal = case
          when lang_dir = match(LANG_DIR)
Severity: Minor
Found in lib/rdf/ntriples/reader.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

Consider simplifying this complex logical expression.
Open

      if @options[:rdfstar] && match(ST_START)
        subject   = read_uriref || read_node || read_quotedTriple || fail_subject
        predicate = read_uriref(intern: true) || fail_predicate
        object    = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
        if !match(ST_END)
Severity: Critical
Found in lib/rdf/ntriples/reader.rb - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

              unless blank? || read_comment
                subject   = read_uriref || read_node || read_quotedTriple || fail_subject
                predicate = read_uriref(intern: true) || fail_predicate
                object    = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
    
    
    Severity: Critical
    Found in lib/rdf/ntriples/reader.rb - About 2 hrs to fix

      Method read_uriref has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def read_uriref(intern: false, **options)
            if uri_str = match(URIREF)
              uri_str = self.class.unescape(uri_str)
              uri = RDF::URI.send(intern? && intern ? :intern : :new, uri_str)
              uri.validate!     if validate?
      Severity: Minor
      Found in lib/rdf/ntriples/reader.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 read_triple has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def read_triple
            loop do
              readline.strip! # EOFError thrown on end of input
              line = @line    # for backtracking input in case of parse error
      
      
      Severity: Minor
      Found in lib/rdf/ntriples/reader.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 unescape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.unescape(string)
            # Note: avoiding copying the input string when no escaping is needed
            # greatly reduces the number of allocations and the processing time.
            string = string.dup.force_encoding(Encoding::UTF_8) unless string.encoding == Encoding::UTF_8
            scanner = StringScanner.new(string)
      Severity: Minor
      Found in lib/rdf/ntriples/reader.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 read_quotedTriple has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def read_quotedTriple
            if @options[:rdfstar] && match(ST_START)
              subject   = read_uriref || read_node || read_quotedTriple || fail_subject
              predicate = read_uriref(intern: true) || fail_predicate
              object    = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
      Severity: Minor
      Found in lib/rdf/ntriples/reader.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

      There are no issues that match your filters.

      Category
      Status