jekyll/jekyll

View on GitHub

Showing 85 issues of 85 total

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

  Options.extract = function(document) {
    var element, keyAndValue, m, mm, options, pair, src, _i, _j, _len, _len1, _ref, _ref1;
    _ref = document.getElementsByTagName('script');
    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
      element = _ref[_i];
Severity: Minor
Found in lib/jekyll/commands/serve/livereload_assets/livereload.js - About 1 hr to fix

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

        Reloader.prototype.reload = function(path, options) {
          var plugin, _base, _i, _len, _ref;
          this.options = options;
          if ((_base = this.options).stylesheetReloadTimeout == null) {
            _base.stylesheetReloadTimeout = 15000;
    Severity: Minor
    Found in lib/jekyll/commands/serve/livereload_assets/livereload.js - About 1 hr to fix

      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 start has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def start(opts)
                  @thread = Thread.new do
                    # Use epoll if the kernel supports it
                    EM.epoll
                    EM.run do
        Severity: Minor
        Found in lib/jekyll/commands/serve/live_reload_reactor.rb - About 1 hr to fix

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

                        case 'cannot-connect':
                          return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + ", will retry in " + nextDelay + " sec.");
          Severity: Major
          Found in lib/jekyll/commands/serve/livereload_assets/livereload.js and 3 other locations - About 1 hr to fix
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 365..366
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 367..368
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 369..370

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

          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 4 locations. Consider refactoring.
          Open

                        case 'handshake-failed':
                          return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake failed), will retry in " + nextDelay + " sec.");
          Severity: Major
          Found in lib/jekyll/commands/serve/livereload_assets/livereload.js and 3 other locations - About 1 hr to fix
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 363..364
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 365..366
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 367..368

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

          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 4 locations. Consider refactoring.
          Open

                        case 'handshake-timeout':
                          return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake timeout), will retry in " + nextDelay + " sec.");
          Severity: Major
          Found in lib/jekyll/commands/serve/livereload_assets/livereload.js and 3 other locations - About 1 hr to fix
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 363..364
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 365..366
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 369..370

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

          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 4 locations. Consider refactoring.
          Open

                        case 'broken':
                          return _this.log("LiveReload disconnected from " + _this.options.host + ":" + _this.options.port + ", reconnecting in " + nextDelay + " sec.");
          Severity: Major
          Found in lib/jekyll/commands/serve/livereload_assets/livereload.js and 3 other locations - About 1 hr to fix
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 363..364
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 367..368
          lib/jekyll/commands/serve/livereload_assets/livereload.js on lines 369..370

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

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

          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 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 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
              Severity
              Category
              Status