ruby-rdf/rdf

View on GitHub
lib/rdf/vocab/writer.rb

Summary

Maintainability
D
2 days
Test Coverage

Method write_epilogue has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

      def write_epilogue
        class_name = options[:class_name]
        module_name = options.fetch(:module_name, "RDF")
        source = options.fetch(:location, base_uri)
        strict = options.fetch(:strict, false)
Severity: Minor
Found in lib/rdf/vocab/writer.rb - About 7 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 write_epilogue has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def write_epilogue
        class_name = options[:class_name]
        module_name = options.fetch(:module_name, "RDF")
        source = options.fetch(:location, base_uri)
        strict = options.fetch(:strict, false)
Severity: Major
Found in lib/rdf/vocab/writer.rb - About 3 hrs to fix

    Method from_node has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def from_node(name, attributes, term_type)
            op = case term_type
            when :property then "property"
            when :ontology then "ontology"
            else                "term"
    Severity: Minor
    Found in lib/rdf/vocab/writer.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

    Method serialize_value has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def serialize_value(value, key, indent: "")
            if value.is_a?(Hash)
              # Favor English
              keys = value.keys
              keys = keys.include?(:en) ? (keys - [:en]).sort.unshift(:en) : keys.sort
    Severity: Minor
    Found in lib/rdf/vocab/writer.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

    Method options has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.options
            [
              RDF::CLI::Option.new(
                symbol: :class_name,
                datatype: String,
    Severity: Minor
    Found in lib/rdf/vocab/writer.rb - About 1 hr to fix

      Method serialize_value has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def serialize_value(value, key, indent: "")
              if value.is_a?(Hash)
                # Favor English
                keys = value.keys
                keys = keys.include?(:en) ? (keys - [:en]).sort.unshift(:en) : keys.sort
      Severity: Minor
      Found in lib/rdf/vocab/writer.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status