atarukodaka/middleman-akcms

View on GitHub

Showing 5 of 5 total issues

Method options_to_config has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def options_to_config
      {
        layout: options.layout,
        summarize: {
          summary_length: options.summary_length,
Severity: Minor
Found in lib/middleman-akcms/extension.rb - About 1 hr to fix

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

        def manipulate_resource_list(resources)
          new_resources = []
          
          resources.each {|res|
            next if res.ignored? || ! res.data.pagination
    Severity: Minor
    Found in lib/middleman-akcms/pagination.rb - About 1 hr to fix

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

          def manipulate_resource_list(resources)
            new_resources = []
            
            resources.each {|res|
              next if res.ignored? || ! res.data.pagination
      Severity: Minor
      Found in lib/middleman-akcms/pagination.rb - About 45 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def render(opts={}, locs={}, &block)
            unless opts.has_key?(:layout)
              opts[:layout] = metadata[:options][:layout]
              opts[:layout] = @app.config.akcms[:layout] if opts[:layout].nil? || opts[:layout] == :_auto_layout
              # Convert to a string unless it's a boolean
      Severity: Minor
      Found in lib/middleman-akcms/article.rb - About 35 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 create_page_resource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def create_page_resource(resource, page_num, metadata = {})
            page_url = @app.config.akcms[:pagination][:page_link] % {page_number: page_num}
            link = resource.path.sub(%r{(^|/)([^/]*)\.([^/]*)$}, "\\1\\2-#{page_url}.\\3")
      
            if resource.is_a? Middleman::Sitemap::ProxyResource
      Severity: Minor
      Found in lib/middleman-akcms/pagination.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

      Severity
      Category
      Status
      Source
      Language