ngs/middleman-ogp

View on GitHub

Showing 5 of 9 total issues

Method ogp_tags has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

        def ogp_tags(&block) # rubocop:disable all
          opts = current_resource.data['ogp'] || {}
          is_blog_article = Middleman::OGP::Helper.blog && respond_to?(:is_blog_article?) && is_blog_article?
          if is_blog_article
            opts.deep_merge4!({
Severity: Minor
Found in lib/middleman-ogp/extension.rb - About 1 day 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 og_tag has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def self.og_tag(key, obj = nil, prefix = 'og', &block) # rubocop:disable Metrics/MethodLength
        case key
        when String, Symbol
          key = [key]
        when Hash
Severity: Minor
Found in lib/middleman-ogp/extension.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 ogp_tags has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def ogp_tags(&block) # rubocop:disable all
          opts = current_resource.data['ogp'] || {}
          is_blog_article = Middleman::OGP::Helper.blog && respond_to?(:is_blog_article?) && is_blog_article?
          if is_blog_article
            opts.deep_merge4!({
Severity: Major
Found in lib/middleman-ogp/extension.rb - About 2 hrs to fix

    Method og_tag has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.og_tag(key, obj = nil, prefix = 'og', &block) # rubocop:disable Metrics/MethodLength
            case key
            when String, Symbol
              key = [key]
            when Hash
    Severity: Minor
    Found in lib/middleman-ogp/extension.rb - About 1 hr to fix

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

            def self.ogp_tags(opts = {}, &block) # rubocop:disable Metrics/MethodLength
              opts ||= {}
              options = (namespaces.respond_to?(:to_h) ? namespaces.to_h : namespaces || {}).dup
              opts.stringify_keys!
              options.stringify_keys!
      Severity: Minor
      Found in lib/middleman-ogp/extension.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

      Severity
      Category
      Status
      Source
      Language