jekyll/jekyll

View on GitHub

Showing 73 of 84 total issues

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

    Reloader.prototype.collectImportedStylesheets = function(link, styleSheet, result) {
      var e, index, rule, rules, _i, _len;
      try {
        rules = styleSheet != null ? styleSheet.cssRules : void 0;
      } catch (_error) {
Severity: Minor
Found in lib/jekyll/commands/serve/livereload_assets/livereload.js - About 1 hr to fix

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

          def calculate(timezone)
            External.require_with_graceful_fail("tzinfo")
            tz = TZInfo::Timezone.get(timezone)
            difference = Time.now.to_i - tz.now.to_i
            #
    Severity: Minor
    Found in lib/jekyll/utils/win_tz.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 read has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def read
          return unless site.theme && 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 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 hash_for_json has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def hash_for_json(state = nil)
            to_h.tap do |hash|
              if state && state.depth >= 2
                hash["previous"] = collapse_document(hash["previous"]) if hash["previous"]
                hash["next"]     = collapse_document(hash["next"]) if hash["next"]
    Severity: Minor
    Found in lib/jekyll/drops/document_drop.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 parse_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_options(input)
            options = {}
            unless input.empty?
              # Split along 3 possible forms -- key="<quoted list>", key=value, or key
              input.scan(%r!(?:\w="[^"]*"|\w=\w|\w)+!) do |opt|
    Severity: Minor
    Found in lib/jekyll/tags/highlight.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

    Function 6 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    },{}],6:[function(require,module,exports){
    (function() {
      var PROTOCOL_6, PROTOCOL_7, Parser, ProtocolError,
        __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
    
    
    Severity: Minor
    Found in lib/jekyll/commands/serve/livereload_assets/livereload.js - 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 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 glob_include? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def glob_include?(enum, e)
          entry = Pathutil.new(site.in_source_dir).join(e)
          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 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 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

    Avoid deeply nested control flow statements.
    Open

                if ((keyAndValue = pair.split('=')).length > 1) {
                  options.set(keyAndValue[0].replace(/-/g, '_'), keyAndValue.slice(1).join('='));
                }
    Severity: Major
    Found in lib/jekyll/commands/serve/livereload_assets/livereload.js - About 45 mins to fix

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

          def add(severity, message = nil, progname = nil)
            severity ||= UNKNOWN
            @logdev = logdevice(severity)
      
            if @logdev.nil? || severity < @level
      Severity: Minor
      Found in lib/jekyll/stevenson.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 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 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 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 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 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 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

        Severity
        Category
        Status
        Source
        Language