middleman/middleman-blog

View on GitHub

Showing 13 of 21 total issues

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

      def manipulate_resource_list(resources)
        @_articles = []
        used_resources = []

        resources.each do |resource|
Severity: Minor
Found in lib/middleman-blog/blog_data.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 article has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def article
        @content = options[:content] || ''
        @date    = options[:date] ? ::Time.zone.parse(options[:date]) : Time.zone.now
        @locale  = options[:locale] || (::I18n.default_locale if defined? ::I18n)
        @slug    = safe_parameterize(title)
Severity: Minor
Found in lib/middleman-blog/commands/article.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 manipulate_resource_list has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def manipulate_resource_list(resources)
        new_resources = []

        resources.each do |res|
          next if res.ignored?
Severity: Minor
Found in lib/middleman-blog/paginator.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 blog_controller has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def blog_controller(blog_name = nil)
        if !blog_name && current_resource
          blog_name = current_resource.metadata[:page][:blog]

          unless blog_name
Severity: Minor
Found in lib/middleman-blog/helpers.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 after_configuration has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def after_configuration
      @name ||= begin
        found_name = nil

        app.extensions[:blog].values.each_with_index do |ext, i|
Severity: Minor
Found in lib/middleman-blog/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

Method date has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def date
        return @_date if @_date

        frontmatter_date = data['date']

Severity: Minor
Found in lib/middleman-blog/blog_article.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 after_configuration has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def after_configuration
      @name ||= begin
        found_name = nil

        app.extensions[:blog].values.each_with_index do |ext, i|
Severity: Minor
Found in lib/middleman-blog/extension.rb - About 1 hr to fix

    Method article has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def article
            @content = options[:content] || ''
            @date    = options[:date] ? ::Time.zone.parse(options[:date]) : Time.zone.now
            @locale  = options[:locale] || (::I18n.default_locale if defined? ::I18n)
            @slug    = safe_parameterize(title)
    Severity: Minor
    Found in lib/middleman-blog/commands/article.rb - About 1 hr to fix

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

            def manipulate_resource_list(resources)
              @_articles = []
              used_resources = []
      
              resources.each do |resource|
      Severity: Minor
      Found in lib/middleman-blog/blog_data.rb - About 1 hr to fix

        Method manipulate_resource_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def manipulate_resource_list(resources)
                new_resources = []
        
                # Set up date pages if the appropriate templates have been specified
                @blog_data.articles.group_by { |a| a.date.year }.each do |year, year_articles|
        Severity: Minor
        Found in lib/middleman-blog/calendar_pages.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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def render(opts = {}, locs = {}, &block)
                unless opts.key?(:layout)
        
                  opts[:layout] = metadata[:options][:layout]
                  opts[:layout] = blog_options.layout if opts[:layout].nil? || opts[:layout] == :_auto_layout
        Severity: Minor
        Found in lib/middleman-blog/blog_article.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

        Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(app, options_hash = {}, &block)
              super
        
              @custom_pages = {}
        
        
        Severity: Minor
        Found in lib/middleman-blog/extension.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

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

              def page_locals(page_num, num_pages, per_page, prev_page_res, articles)
        Severity: Minor
        Found in lib/middleman-blog/paginator.rb - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language