SebastianCarroll/jekyll-rakefile

View on GitHub

Showing 319 of 319 total issues

OS Command Injection in Rake
Open

    rake (10.4.2)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-8130

Criticality: High

URL: https://github.com/advisories/GHSA-jppv-gw3r-w3q8

Solution: upgrade to >= 12.3.3

json Gem for Ruby Unsafe Object Creation Vulnerability (additional fix)
Open

    json (2.0.3)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-10663

Criticality: High

URL: https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/

Solution: upgrade to >= 2.3.0

Method has too many lines. [30/10]
Open

def check_links
  begin
    require 'anemone'

    root = 'http://localhost:4000/'
Severity: Minor
Found in lib/tools.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for check_links is too high. [25.4/15]
Open

def check_links
  begin
    require 'anemone'

    root = 'http://localhost:4000/'
Severity: Minor
Found in lib/tools.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [15/10]
Open

    def write_new_draft()
      filename = get_unique_filename
      full_path = File.join(@post_dir, filename)
      File.open(full_path, 'w') do |f|
        f.puts "---"
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for parse_date is too high. [8/6]
Open

    def parse_date(date)
      # This looks cleaner but logic is incorrect
      #if (date.nil? ||
      #    date.empty? ||
      #    date.match(/[0-9]+-[0-9]+-[0-9]+/).nil?) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for parse_date is too high. [8/7]
Open

    def parse_date(date)
      # This looks cleaner but logic is incorrect
      #if (date.nil? ||
      #    date.empty? ||
      #    date.match(/[0-9]+-[0-9]+-[0-9]+/).nil?) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Assignment Branch Condition size for get_unique_filename is too high. [16.79/15]
Open

    def  get_unique_filename()
      # TODO: Global Variable
      filename = @date[0..9] + "-" + JekyllRake::Utils.slugify(@title) + $post_ext

      # TODO: refactor - very difficult to understand without the comment
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for parse_date is too high. [15.65/15]
Open

    def parse_date(date)
      # This looks cleaner but logic is incorrect
      #if (date.nil? ||
      #    date.empty? ||
      #    date.match(/[0-9]+-[0-9]+-[0-9]+/).nil?) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for write_new_draft is too high. [15.26/15]
Open

    def write_new_draft()
      filename = get_unique_filename
      full_path = File.join(@post_dir, filename)
      File.open(full_path, 'w') do |f|
        f.puts "---"
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method check_links has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def check_links
  begin
    require 'anemone'

    root = 'http://localhost:4000/'
Severity: Minor
Found in lib/tools.rb - About 1 hr to fix

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

    def check_links
      begin
        require 'anemone'
    
        root = 'http://localhost:4000/'
    Severity: Minor
    Found in lib/tools.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

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

        def  set_post_dir_and_yaml_cat(dir)
          # Written like this to deal with category being nil
          if @category and Dir.exists?(File.join(@category, dir)) then
            @post_dir = File.join(@category, dir)
            @yaml_cat = nil
    Severity: Minor
    Found in lib/jekyll_rake/post.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

    Block has too many lines. [26/25]
    Open

    Gem::Specification.new do |spec|
      spec.name          = "jekyll_rake"
      spec.version       = JekyllRake::VERSION
      spec.authors       = ["Sebastian Carroll"]
      spec.email         = ["scarroll@hortonworks.com"]
    Severity: Minor
    Found in jekyll_rake.gemspec by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency codeclimate-test-reporter should appear before simplecov.
    Open

      spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
    Severity: Minor
    Found in jekyll_rake.gemspec by rubocop

    Dependencies in the gemspec should be alphabetically sorted.

    Example:

    # bad
    spec.add_dependency 'rubocop'
    spec.add_dependency 'rspec'
    
    # good
    spec.add_dependency 'rspec'
    spec.add_dependency 'rubocop'
    
    # good
    spec.add_dependency 'rubocop'
    
    spec.add_dependency 'rspec'
    
    # bad
    spec.add_development_dependency 'rubocop'
    spec.add_development_dependency 'rspec'
    
    # good
    spec.add_development_dependency 'rspec'
    spec.add_development_dependency 'rubocop'
    
    # good
    spec.add_development_dependency 'rubocop'
    
    spec.add_development_dependency 'rspec'
    
    # bad
    spec.add_runtime_dependency 'rubocop'
    spec.add_runtime_dependency 'rspec'
    
    # good
    spec.add_runtime_dependency 'rspec'
    spec.add_runtime_dependency 'rubocop'
    
    # good
    spec.add_runtime_dependency 'rubocop'
    
    spec.add_runtime_dependency 'rspec'
    
    # good only if TreatCommentsAsGroupSeparators is true
    # For code quality
    spec.add_dependency 'rubocop'
    # For tests
    spec.add_dependency 'rspec'

    Line is too long. [108/80]
    Open

        puts "Building while running other tasks (e.g., preview), might create a website with broken links.\n\n"
    Severity: Minor
    Found in Rakefile.deploy.rb by rubocop

    Line is too long. [112/80]
    Open

      %x{git add -A && git commit -m "autopush by Rakefile at #{time}" && git push origin gh_pages} if $git_autopush
    Severity: Minor
    Found in Rakefile.deploy.rb by rubocop

    Do not introduce global variables.
    Open

        %x{git add -A && git commit -m "autopush by Rakefile at #{time}" && git push} if $git_autopush
    Severity: Minor
    Found in Rakefile.deploy.rb by rubocop

    This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

    Note that backreferences like $1, $2, etc are not global variables.

    Example:

    # bad
    $foo = 2
    bar = $foo + 5
    
    # good
    FOO = 2
    foo = 2
    $stdin.read

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

      out_dir = "images"
    Severity: Minor
    Found in Rakefile.deploy.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

      t.libs << "lib"
    Severity: Minor
    Found in Rakefile by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"
    Severity
    Category
    Status
    Source
    Language