sverrirs/jekyll-paginate-v2

View on GitHub

Showing 200 of 201 total issues

Method paginate has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales)
Severity: Major
Found in lib/jekyll-paginate-v2/generator/paginationModel.rb - About 50 mins to fix

    Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(site, base, autopage_config, pagination_config, layout_name, category, category_name)
    Severity: Major
    Found in lib/jekyll-paginate-v2/autopages/pages/categoryAutoPage.rb - About 50 mins to fix

      Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(site, base, autopage_config, pagination_config, layout_name, tag, tag_name)
      Severity: Major
      Found in lib/jekyll-paginate-v2/autopages/pages/tagAutoPage.rb - About 50 mins to fix

        Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(site, base, autopage_config, pagination_config, layout_name, collection, collection_name)
        Severity: Major
        Found in lib/jekyll-paginate-v2/autopages/pages/collectionAutoPage.rb - About 50 mins to fix

          Method autopage_create has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def self.autopage_create(autopage_config, pagination_config, posts_to_use, configkey_name, indexkey_name, createpage_lambda )
          Severity: Minor
          Found in lib/jekyll-paginate-v2/autopages/autoPages.rb - About 45 mins to fix

            Method read_config_value_and_filter_posts has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def self.read_config_value_and_filter_posts(config, config_key, posts, source_posts, should_union = false)
            Severity: Minor
            Found in lib/jekyll-paginate-v2/generator/paginationIndexer.rb - About 35 mins to fix

              Avoid too many return statements within this method.
              Open

                      return posts if config[config_key].nil?
              Severity: Major
              Found in lib/jekyll-paginate-v2/generator/paginationIndexer.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return a <=> b
                Severity: Major
                Found in lib/jekyll-paginate-v2/generator/utils.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return posts
                  Severity: Major
                  Found in lib/jekyll-paginate-v2/generator/paginationIndexer.rb - About 30 mins to fix

                    Method sort_values has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def self.sort_values(a, b)
                            if a.nil? && !b.nil?
                              return -1
                            elsif !a.nil? && b.nil?
                              return 1
                    Severity: Minor
                    Found in lib/jekyll-paginate-v2/generator/utils.rb - About 25 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

                    Use a guard clause instead of wrapping the code inside a conditional expression.
                    Open

                            if @debug

                    Use a guard clause instead of wrapping the code inside a conditional expression

                    Example:

                    # bad
                    def test
                      if something
                        work
                      end
                    end
                    
                    # good
                    def test
                      return unless something
                      work
                    end
                    
                    # also good
                    def test
                      work if something
                    end
                    
                    # bad
                    if something
                      raise 'exception'
                    else
                      ok
                    end
                    
                    # good
                    raise 'exception' if something
                    ok

                    Use a guard clause instead of wrapping the code inside a conditional expression.
                    Open

                            if( config['trail'] && !config['trail'].nil? && newpages.size.to_i > 1 )

                    Use a guard clause instead of wrapping the code inside a conditional expression

                    Example:

                    # bad
                    def test
                      if something
                        work
                      end
                    end
                    
                    # good
                    def test
                      return unless something
                      work
                    end
                    
                    # also good
                    def test
                      work if something
                    end
                    
                    # bad
                    if something
                      raise 'exception'
                    else
                      ok
                    end
                    
                    # good
                    raise 'exception' if something
                    ok

                    Redundant self detected.
                    Open

                            self._debug_print_filtering_info('Category', before, using_posts.size.to_i)

                    This cop checks for redundant uses of self.

                    The usage of self is only needed when:

                    • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

                    • Calling an attribute writer to prevent an local variable assignment.

                    Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

                    Note we allow uses of self with operators because it would be awkward otherwise.

                    Example:

                    # bad
                    def foo(bar)
                      self.baz
                    end
                    
                    # good
                    def foo(bar)
                      self.bar  # Resolves name clash with the argument.
                    end
                    
                    def foo
                      bar = 1
                      self.bar  # Resolves name clash with the local variable.
                    end
                    
                    def foo
                      %w[x y z].select do |bar|
                        self.bar == bar  # Resolves name clash with argument of the block.
                      end
                    end

                    Use 2 (not -6) spaces for indentation.
                    Open

                                PaginationIndexer.union_arrays(posts, source_posts[key])

                    This cops checks for indentation that doesn't use the specified number of spaces.

                    See also the IndentationConsistency cop which is the companion to this one.

                    Example:

                    # bad
                    class A
                     def test
                      puts 'hello'
                     end
                    end
                    
                    # good
                    class A
                      def test
                        puts 'hello'
                      end
                    end

                    Example: IgnoredPatterns: ['^\s*module']

                    # bad
                    module A
                    class B
                      def test
                      puts 'hello'
                      end
                    end
                    end
                    
                    # good
                    module A
                    class B
                      def test
                        puts 'hello'
                      end
                    end
                    end

                    Extra empty line detected at module body beginning.
                    Open

                    
                        class BaseAutoPage < Jekyll::Page

                    This cops checks if empty lines around the bodies of modules match the configuration.

                    Example: EnforcedStyle: empty_lines

                    # good
                    
                    module Foo
                    
                      def bar
                        # ...
                      end
                    
                    end

                    Example: EnforcedStyle: emptylinesexcept_namespace

                    # good
                    
                    module Foo
                      module Bar
                    
                        # ...
                    
                      end
                    end

                    Example: EnforcedStyle: emptylinesspecial

                    # good
                    module Foo
                    
                      def bar; end
                    
                    end

                    Example: EnforcedStyle: noemptylines (default)

                    # good
                    
                    module Foo
                      def bar
                        # ...
                      end
                    end

                    Redundant self detected.
                    Open

                            self.data['permalink'] = permalink_formatted

                    This cop checks for redundant uses of self.

                    The usage of self is only needed when:

                    • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

                    • Calling an attribute writer to prevent an local variable assignment.

                    Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

                    Note we allow uses of self with operators because it would be awkward otherwise.

                    Example:

                    # bad
                    def foo(bar)
                      self.baz
                    end
                    
                    # good
                    def foo(bar)
                      self.bar  # Resolves name clash with the argument.
                    end
                    
                    def foo
                      bar = 1
                      self.bar  # Resolves name clash with the local variable.
                    end
                    
                    def foo
                      %w[x y z].select do |bar|
                        self.bar == bar  # Resolves name clash with argument of the block.
                      end
                    end

                    Use Hash#key? instead of Hash#has_key?.
                    Open

                            slugify_config = autopage_config.is_a?(Hash) && autopage_config.has_key?('slugify') ? autopage_config['slugify'] : nil

                    This cop (by default) checks for uses of methods Hash#haskey? and Hash#hasvalue? where it enforces Hash#key? and Hash#value? It is configurable to enforce the inverse, using verbose method names also.

                    Example: EnforcedStyle: short (default)

                    # bad Hash#haskey? Hash#hasvalue?

                    # good Hash#key? Hash#value?

                    Example: EnforcedStyle: verbose

                    # bad Hash#key? Hash#value?

                    # good Hash#haskey? Hash#hasvalue?

                    Redundant return detected.
                    Open

                            return index

                    This cop checks for redundant return expressions.

                    Example:

                    def test
                      return something
                    end
                    
                    def test
                      one
                      two
                      three
                      return something
                    end

                    It should be extended to handle methods whose body is if/else or a case expression with a default branch.

                    Extra empty line detected at module body end.
                    Open

                    
                      end # module PaginateV2

                    This cops checks if empty lines around the bodies of modules match the configuration.

                    Example: EnforcedStyle: empty_lines

                    # good
                    
                    module Foo
                    
                      def bar
                        # ...
                      end
                    
                    end

                    Example: EnforcedStyle: emptylinesexcept_namespace

                    # good
                    
                    module Foo
                      module Bar
                    
                        # ...
                    
                      end
                    end

                    Example: EnforcedStyle: emptylinesspecial

                    # good
                    module Foo
                    
                      def bar; end
                    
                    end

                    Example: EnforcedStyle: noemptylines (default)

                    # good
                    
                    module Foo
                      def bar
                        # ...
                      end
                    end

                    Extra empty line detected at module body end.
                    Open

                    
                      end # module PaginateV2

                    This cops checks if empty lines around the bodies of modules match the configuration.

                    Example: EnforcedStyle: empty_lines

                    # good
                    
                    module Foo
                    
                      def bar
                        # ...
                      end
                    
                    end

                    Example: EnforcedStyle: emptylinesexcept_namespace

                    # good
                    
                    module Foo
                      module Bar
                    
                        # ...
                    
                      end
                    end

                    Example: EnforcedStyle: emptylinesspecial

                    # good
                    module Foo
                    
                      def bar; end
                    
                    end

                    Example: EnforcedStyle: noemptylines (default)

                    # good
                    
                    module Foo
                      def bar
                        # ...
                      end
                    end
                    Severity
                    Category
                    Status
                    Source
                    Language