jekyll/jekyll

View on GitHub

Showing 59 of 59 total issues

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

        def init_with_program(prog)
          prog.command(:serve) do |cmd|
            cmd.description "Serve your site locally"
            cmd.syntax "serve [options]"
            cmd.alias :server
Severity: Minor
Found in lib/jekyll/commands/serve.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 load_cached_partial has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def load_cached_partial(path, context)
        context.registers[:cached_partials] ||= {}
        cached_partial = context.registers[:cached_partials]

        if cached_partial.key?(path)
Severity: Minor
Found in lib/jekyll/tags/include.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 read_yaml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def read_yaml(base, name, opts = {})
      filename = File.join(base, name)

      begin
        self.content = File.read(@path || site.in_source_dir(base, name),
Severity: Minor
Found in lib/jekyll/convertible.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 read_publishable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def read_publishable(dir, magic_dir, matcher)
      read_content(dir, magic_dir, matcher).tap { |docs| docs.each(&:read) }
        .select do |doc|
          if doc.content.valid_encoding?
            site.publisher.publish?(doc).tap do |will_publish|
Severity: Minor
Found in lib/jekyll/readers/post_reader.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 read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def read
      return unless site.theme&.assets_path

      Find.find(site.theme.assets_path) do |path|
        next if File.directory?(path)
Severity: Minor
Found in lib/jekyll/readers/theme_assets_reader.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 glob_include? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def glob_include?(enum, entry)
      entry_path = Pathutil.new(site.in_source_dir).join(entry)
      enum.any? do |exp|
        # Users who send a Regexp knows what they want to
        # exclude, so let them send a Regexp to exclude files,
Severity: Minor
Found in lib/jekyll/entry_filter.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(site, base, dir, name, collection = nil)
Severity: Minor
Found in lib/jekyll/static_file.rb - About 35 mins to fix

    Method applies_path? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def applies_path?(scope, path)
          return true if !scope.key?("path") || scope["path"].empty?
    
          sanitized_path = Pathname.new(sanitize_path(path))
          site_path      = Pathname.new(@site.source)
    Severity: Minor
    Found in lib/jekyll/frontmatter_defaults.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 sort_by_property_directly has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def sort_by_property_directly(docs, meta_key)
      docs.sort! do |apple, orange|
        apple_property = apple[meta_key]
        orange_property = orange[meta_key]
    
    
    Severity: Minor
    Found in benchmark/schwartzian_transform.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 require_theme_deps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def require_theme_deps
          return false unless site.theme.runtime_dependencies
          site.theme.runtime_dependencies.each do |dep|
            next if dep.name == "jekyll"
            External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name)
    Severity: Minor
    Found in lib/jekyll/plugin_manager.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 fetch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def fetch(key, default = nil, &block)
            return self[key] if key?(key)
            raise KeyError, %(key not found: "#{key}") if default.nil? && block.nil?
            return yield(key) unless block.nil?
            return default unless default.nil?
    Severity: Minor
    Found in lib/jekyll/drops/drop.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 add_dependency has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_dependency(path, dependency)
          return if metadata[path].nil? || disabled
    
          unless metadata[path]["deps"].include? dependency
            metadata[path]["deps"] << dependency
    Severity: Minor
    Found in lib/jekyll/regenerator.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 place_in_layouts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def place_in_layouts(content, payload, info)
          output = content.dup
          layout = layouts[document.data["layout"].to_s]
          validate_layout(layout)
    
    
    Severity: Minor
    Found in lib/jekyll/renderer.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 regenerate? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def regenerate?(document)
          return true if disabled
          case document
          when Page
            regenerate_page?(document)
    Severity: Minor
    Found in lib/jekyll/regenerator.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 bundle_install has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def bundle_install(path)
              Jekyll.logger.info "Running bundle install in #{path.cyan}..."
              Dir.chdir(path) do
                exe = Gem.bin_path("bundler", "bundle")
                process, output = Jekyll::Utils::Exec.run("ruby", exe, "install")
    Severity: Minor
    Found in lib/jekyll/commands/new.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 schwartzian_transform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def schwartzian_transform(docs, meta_key)
      docs.collect! { |d|
        [d[meta_key], d]
      }.sort! { |apple, orange|
        if !apple[0].nil? && !orange[0].nil?
    Severity: Minor
    Found in benchmark/schwartzian_transform.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 stop_callback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def stop_callback(detached)
              unless detached
                proc do
                  mutex.synchronize do
                    unless @reload_reactor.nil?
    Severity: Minor
    Found in lib/jekyll/commands/serve.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 sort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def sort(input, property = nil, nils = "first")
          raise ArgumentError, "Cannot sort a null object." if input.nil?
          if property.nil?
            input.sort
          else
    Severity: Minor
    Found in lib/jekyll/filters.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

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

    Benchmark.ips do |x|
      x.config(time: 10, warmup: 5)
      x.report('sort_by_property_directly with non-sparse property') do
        sort_by_property_directly(site_docs, "title".freeze)
      end
    Severity: Minor
    Found in benchmark/schwartzian_transform.rb and 1 other location - About 25 mins to fix
    benchmark/schwartzian_transform.rb on lines 94..102

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

    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

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

        def sort_input(input, property, order)
          input.map { |item| [item_property(item, property), item] }
            .sort! do |a_info, b_info|
              a_property = a_info.first
              b_property = b_info.first
    Severity: Minor
    Found in lib/jekyll/filters.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