Showing 4 of 4 total issues

Method to_mtif has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def to_mtif
      result = []
      single_line_single_value_keys.each do |key|
        value = self.send(key)
        next if value.nil? || (value.respond_to?(:empty) && value.empty?)
Severity: Minor
Found in lib/mtif/posts.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 to_mtif has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def to_mtif
      result = []
      single_line_single_value_keys.each do |key|
        value = self.send(key)
        next if value.nil? || (value.respond_to?(:empty) && value.empty?)
Severity: Minor
Found in lib/mtif/posts.rb - About 1 hr to fix

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

        def store_data(raw_key, raw_value)
          key = mtif_key_to_key(raw_key)
          value = convert_to_native_type(raw_value)
    
          if MULTIVALUE_KEYS.include?(key)
    Severity: Minor
    Found in lib/mtif/posts.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 parse_source has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_source
          source.slice_before(/^#{FIELD_SEPARATOR}/).each do |lines|
            if lines.first =~ /^#{FIELD_SEPARATOR}/ && lines.size > 1
              # Multiline data
              store_data(lines.shift(2).last.chomp(":\n"), lines.join.strip)
    Severity: Minor
    Found in lib/mtif/posts.rb - About 55 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

    Severity
    Category
    Status
    Source
    Language