middleman/middleman-blog

View on GitHub

Showing 26 of 26 total issues

Function pjax has 145 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var pjax = $.pjax = function( options ) {

  // options from handleClick fn
  options = $.extend({}, $.ajaxSettings, pjax.defaults, options);

Severity: Major
Found in fixtures/default-template-app/source/javascripts/_zepto.pjax.js - About 5 hrs to fix

    File _zepto.pjax.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // zepto.pjax.js
    // copyright chris wanstrath
    // https://github.com/defunkt/jquery-pjax
    // https://github.com/shogun70/jquery-pjax - duration
    // https://github.com/jimisaacs/zepto-pjax
    Severity: Minor
    Found in fixtures/default-template-app/source/javascripts/_zepto.pjax.js - About 5 hrs to fix

      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 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 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 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

        Function beforeSend has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          options.beforeSend = function(xhr, settings) {
            var timeout = settings.timeout;
            if (settings.timeout > 0) {
              timeoutTimer = setTimeout(function() {
                if (fire('pjax:timeout', [xhr, options]))
        Severity: Minor
        Found in fixtures/default-template-app/source/javascripts/_zepto.pjax.js - 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

            Function _success has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function _success(data, status, xhr) {
                var container = extractContainer(data, xhr, options);
            
                if (!container.contents) {
                  window.location = container.url;
            Severity: Minor
            Found in fixtures/default-template-app/source/javascripts/_zepto.pjax.js - 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

                Function pjax has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  $.pjax = function( options ) {
                    var url = $.isFunction(options.url) ? options.url() : options.url,
                        method = options.type ? options.type.toUpperCase() : 'GET';
                
                    var form = $('<form>', {
                Severity: Minor
                Found in fixtures/default-template-app/source/javascripts/_zepto.pjax.js - About 1 hr to fix

                  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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    activate :blog do |blog2|
                      blog2.name              = 'blog_name_2'
                      blog2.prefix            = 'blog2'
                      blog2.sources           = ':year-:month-:day-:title.html'
                      blog2.permalink         = ':year-:month-:day-:title.html'
                    Severity: Minor
                    Found in fixtures/paginate-multiblog-app/config.rb and 1 other location - About 25 mins to fix
                    fixtures/paginate-multiblog-app/config.rb on lines 3..11

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 29.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    activate :blog do |blog|
                      blog.name              = 'blog_name_1'
                      blog.prefix            = 'blog1'
                      blog.sources           = ':year-:month-:day-:title.html'
                      blog.permalink         = ':year-:month-:day-:title.html'
                    Severity: Minor
                    Found in fixtures/paginate-multiblog-app/config.rb and 1 other location - About 25 mins to fix
                    fixtures/paginate-multiblog-app/config.rb on lines 14..22

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 29.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language