crispgm/jekyll-tags-list-plugin

View on GitHub

Showing 9 of 9 total issues

Method parse_params has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_params
        params = @text.split(',')
        params.each do |param|
          key_vals = param.split('=>', 2)
          param_name = key_vals[0].strip
Severity: Minor
Found in lib/jekyll-tagslist/tagslist_tag.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 render has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def render(context)
        tags = context.registers[:site].tags.map do |tag, posts|
          [tag, posts.count] if posts.count >= @threshold
        end

Severity: Minor
Found in lib/jekyll-tagslist/tagslist_tag.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

Cyclomatic complexity for parse_params is too high. [12/6]
Open

      def parse_params
        params = @text.split(',')
        params.each do |param|
          key_vals = param.split('=>', 2)
          param_name = key_vals[0].strip
Severity: Minor
Found in lib/jekyll-tagslist/tagslist_tag.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method has too many lines. [34/30]
Open

      def render(context)
        tags = context.registers[:site].tags.map do |tag, posts|
          [tag, posts.count] if posts.count >= @threshold
        end

Severity: Minor
Found in lib/jekyll-tagslist/tagslist_tag.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for render is too high. [10/6]
Open

      def render(context)
        tags = context.registers[:site].tags.map do |tag, posts|
          [tag, posts.count] if posts.count >= @threshold
        end

Severity: Minor
Found in lib/jekyll-tagslist/tagslist_tag.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method render has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def render(context)
        tags = context.registers[:site].tags.map do |tag, posts|
          [tag, posts.count] if posts.count >= @threshold
        end

Severity: Minor
Found in lib/jekyll-tagslist/tagslist_tag.rb - About 1 hr to fix

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

          def parse_params
            params = @text.split(',')
            params.each do |param|
              key_vals = param.split('=>', 2)
              param_name = key_vals[0].strip
    Severity: Minor
    Found in lib/jekyll-tagslist/tagslist_tag.rb - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                  if param_value.eql? 'time'
                    @sort_by  = 'time'
                  elsif param_value.eql? 'count'
                    @sort_by  = 'count'
                  else
      Severity: Major
      Found in lib/jekyll-tagslist/tagslist_tag.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  elsif param_name.eql? ':limit'
                    param_value = param_value.to_i
                    @limit = param_value if param_value > 0
                  else
                    next
        Severity: Major
        Found in lib/jekyll-tagslist/tagslist_tag.rb - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language