SebastianCarroll/jekyll-rakefile

View on GitHub
lib/jekyll_rake/post.rb

Summary

Maintainability
A
25 mins
Test Coverage

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.

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

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

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

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

TODO found
Open

      # TODO: Add logic here to account for nul title?
Severity: Minor
Found in lib/jekyll_rake/post.rb by fixme

TODO found
Open

    # TODO: No error handling
Severity: Minor
Found in lib/jekyll_rake/post.rb by fixme

TODO found
Open

      # TODO: Global Variable
Severity: Minor
Found in lib/jekyll_rake/post.rb by fixme

TODO found
Open

      # TODO: What is this? Too complex
Severity: Minor
Found in lib/jekyll_rake/post.rb by fixme

TODO found
Open

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

TODO found
Open

      # TODO: This method is still out of place
Severity: Minor
Found in lib/jekyll_rake/post.rb by fixme

Trailing whitespace detected.
Open

      end 
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Use && instead of and.
Open

      if @category and Dir.exists?(File.join(@category, dir)) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Do not use then for multi-line if.
Open

      if @category and Dir.exists?(File.join(@category, dir)) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Checks for uses of the then keyword in multi-line if statements.

Example:

# bad
# This is considered bad practice.
if cond then
end

# good
# If statements can contain `then` on the same line.
if cond then a
elsif cond then b
end

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

      filename = @date[0..9] + "-" + JekyllRake::Utils.slugify(@title) + $post_ext
Severity: Minor
Found in lib/jekyll_rake/post.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

        puts "Usage: create_post[title,content,date,category]"
Severity: Minor
Found in lib/jekyll_rake/post.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"

Line is too long. [90/80]
Open

      puts "DATE is in the form: YYYY-MM-DD; use nil or the empty string for today's date"
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Use && instead of and.
Open

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Use && instead of and.
Open

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

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

        f.puts "layout: default"
Severity: Minor
Found in lib/jekyll_rake/post.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"

Unnecessary spacing detected.
Open

    def  get_unique_filename()
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Line is too long. [82/80]
Open

      filename = @date[0..9] + "-" + JekyllRake::Utils.slugify(@title) + $post_ext
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

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

        f.puts "---"
Severity: Minor
Found in lib/jekyll_rake/post.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"

Do not use do with multi-line while.
Open

      while File.exists?(@post_dir + filename) do
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Checks for uses of do in multi-line while/until statements.

Example:

# bad
while x.any? do
  do_something(x.pop)
end

# good
while x.any?
  do_something(x.pop)
end

Example:

# bad
until x.empty? do
  do_something(x.pop)
end

# good
until x.empty?
  do_something(x.pop)
end

Line is too long. [82/80]
Open

      puts "          create_post[#{Time.new.strftime("%Y-%m-%d")},\"#{@title}\"]"
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Do not introduce global variables.
Open

      filename = @date[0..9] + "-" + JekyllRake::Utils.slugify(@title) + $post_ext
Severity: Minor
Found in lib/jekyll_rake/post.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

Do not use then for multi-line if.
Open

          date.match(/[0-9]+-[0-9]+-[0-9]+/) == nil) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Checks for uses of the then keyword in multi-line if statements.

Example:

# bad
# This is considered bad practice.
if cond then
end

# good
# If statements can contain `then` on the same line.
if cond then a
elsif cond then b
end

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

        puts "CATEGORY is a string; nil or empty for no category"
Severity: Minor
Found in lib/jekyll_rake/post.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

      puts "Usage: create_post[date,title,category,content]"
Severity: Minor
Found in lib/jekyll_rake/post.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 !expression.nil? over expression != nil.
Open

        f.puts @yaml_cat if @yaml_cat != nil
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for non-nil checks, which are usually redundant.

Example:

# bad
if x != nil
end

# good (when not allowing semantic changes)
# bad (when allowing semantic changes)
if !x.nil?
end

# good (when allowing semantic changes)
if x
end

Non-nil checks are allowed if they are the final nodes of predicate.

# good
def signed_in?
  !current_user.nil?
end

Dir.exists? is deprecated in favor of Dir.exist?.
Open

      if @category and Dir.exists?(File.join(@category, dir)) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of the deprecated class method usages.

Example:

# bad

File.exists?(some_path)

Example:

# good

File.exist?(some_path)

Unused method argument - t. If it's necessary, use _ or _t as an argument name to indicate that it won't be used.
Open

    def initialize(t, args, dir)
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

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

      puts ""
Severity: Minor
Found in lib/jekyll_rake/post.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"

Use && instead of and.
Open

          date != "nil" and
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Missing top-level class documentation comment.
Open

  class Post 
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

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

        filename = @date[0..9] + "-" +
Severity: Minor
Found in lib/jekyll_rake/post.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

      puts "CATEGORY is a string; nil or empty for no category"
Severity: Minor
Found in lib/jekyll_rake/post.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"

Omit parentheses for ternary conditions.
Open

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for the presence of parentheses around ternary conditions. It is configurable to enforce inclusion or omission of parentheses using EnforcedStyle. Omission is only enforced when removing the parentheses won't cause a different behavior.

Example: EnforcedStyle: requirenoparentheses (default)

# bad
foo = (bar?) ? a : b
foo = (bar.baz?) ? a : b
foo = (bar && baz) ? a : b

# good
foo = bar? ? a : b
foo = bar.baz? ? a : b
foo = bar && baz ? a : b

Example: EnforcedStyle: require_parentheses

# bad
foo = bar? ? a : b
foo = bar.baz? ? a : b
foo = bar && baz ? a : b

# good
foo = (bar?) ? a : b
foo = (bar.baz?) ? a : b
foo = (bar && baz) ? a : b

Example: EnforcedStyle: requireparentheseswhen_complex

# bad
foo = (bar?) ? a : b
foo = (bar.baz?) ? a : b
foo = bar && baz ? a : b

# good
foo = bar? ? a : b
foo = bar.baz? ? a : b
foo = (bar && baz) ? a : b

Omit the parentheses in defs when the method doesn't accept any arguments.
Open

    def write_new_draft()
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for parentheses in the definition of a method, that does not take any arguments. Both instance and class/singleton methods are checked.

Example:

# bad
def foo()
  # does a thing
end

# good
def foo
  # does a thing
end

# also good
def foo() does_a_thing end

Example:

# bad
def Baz.foo()
  # does a thing
end

# good
def Baz.foo
  # does a thing
end

Omit the parentheses in defs when the method doesn't accept any arguments.
Open

    def  get_unique_filename()
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for parentheses in the definition of a method, that does not take any arguments. Both instance and class/singleton methods are checked.

Example:

# bad
def foo()
  # does a thing
end

# good
def foo
  # does a thing
end

# also good
def foo() does_a_thing end

Example:

# bad
def Baz.foo()
  # does a thing
end

# good
def Baz.foo
  # does a thing
end

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

        puts "DATE and CATEGORY are optional"
Severity: Minor
Found in lib/jekyll_rake/post.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"

Trailing whitespace detected.
Open

  class Post 
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Use && instead of and.
Open

          date != "" and
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Don't use parentheses around the condition of an if.
Open

      if (date != nil and
          date != "nil" and
          date != "" and
          date.match(/[0-9]+-[0-9]+-[0-9]+/) == nil) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for the presence of superfluous parentheses around the condition of if/unless/while/until.

Example:

# bad
x += 1 while (x < 10)
foo unless (bar || baz)

if (x > 10)
elsif (x < 3)
end

# good
x += 1 while x < 10
foo unless bar || baz

if x > 10
elsif x < 3
end

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

          date != "" and
Severity: Minor
Found in lib/jekyll_rake/post.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"

Do not introduce global variables.
Open

          $post_ext
Severity: Minor
Found in lib/jekyll_rake/post.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 !expression.nil? over expression != nil.
Open

      if (date != nil and
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for non-nil checks, which are usually redundant.

Example:

# bad
if x != nil
end

# good (when not allowing semantic changes)
# bad (when allowing semantic changes)
if !x.nil?
end

# good (when allowing semantic changes)
if x
end

Non-nil checks are allowed if they are the final nodes of predicate.

# good
def signed_in?
  !current_user.nil?
end

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

        f.puts ""
Severity: Minor
Found in lib/jekyll_rake/post.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 inside interpolations.
Open

      puts "          create_post[#{Time.new.strftime("%Y-%m-%d")},\"#{@title}\"]"
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks that quotes inside the string interpolation match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
result = "Tests #{success ? "PASS" : "FAIL"}"

# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"

Example: EnforcedStyle: double_quotes

# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"

# good
result = "Tests #{success ? "PASS" : "FAIL"}"

Do not prefix writer method names with set_.
Open

    def  set_post_dir_and_yaml_cat(dir)
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop makes sure that accessor methods are named properly.

Example:

# bad
def set_attribute(value)
end

# good
def attribute=(value)
end

# bad
def get_attribute
end

# good
def attribute
end

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

        f.puts "---"
Severity: Minor
Found in lib/jekyll_rake/post.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

          date != "nil" and
Severity: Minor
Found in lib/jekyll_rake/post.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

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.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 the use of the nil? predicate.
Open

      if title == nil then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for comparison of something with nil using ==.

Example:

# bad
if x == nil
end

# good
if x.nil?
end

Prefer the use of the nil? predicate.
Open

          date.match(/[0-9]+-[0-9]+-[0-9]+/) == nil) then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for comparison of something with nil using ==.

Example:

# bad
if x == nil
end

# good
if x.nil?
end

Do not prefix reader method names with get_.
Open

    def  get_unique_filename()
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop makes sure that accessor methods are named properly.

Example:

# bad
def set_attribute(value)
end

# good
def attribute=(value)
end

# bad
def get_attribute
end

# good
def attribute
end

Do not use then for multi-line if.
Open

      if title == nil then
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Checks for uses of the then keyword in multi-line if statements.

Example:

# bad
# This is considered bad practice.
if cond then
end

# good
# If statements can contain `then` on the same line.
if cond then a
elsif cond then b
end

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

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.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"

Missing space after #.
Open

      #if (date.nil? ||
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

Example:

# bad
#Some comment

# good
# Some comment

Align the operands of an expression in an assignment spanning multiple lines.
Open

          File.basename(JekyllRake::Utils.slugify(@title)) + "-" + i.to_s +
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

File.exists? is deprecated in favor of File.exist?.
Open

      while File.exists?(@post_dir + filename) do
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of the deprecated class method usages.

Example:

# bad

File.exists?(some_path)

Example:

# good

File.exist?(some_path)

Line is too long. [81/80]
Open

        puts "DATE is in the form: YYYY-MM-DD; use nil or empty for today's date"
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

Line is too long. [105/80]
Open

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

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

        puts "Error! title is empty"
Severity: Minor
Found in lib/jekyll_rake/post.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

        puts "Error: Date not understood"
Severity: Minor
Found in lib/jekyll_rake/post.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"

Use && instead of and.
Open

      if (date != nil and
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Prefer !expression.nil? over expression != nil.
Open

        f.puts @content if @content != nil
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for non-nil checks, which are usually redundant.

Example:

# bad
if x != nil
end

# good (when not allowing semantic changes)
# bad (when allowing semantic changes)
if !x.nil?
end

# good (when allowing semantic changes)
if x
end

Non-nil checks are allowed if they are the final nodes of predicate.

# good
def signed_in?
  !current_user.nil?
end

Use ! instead of not.
Open

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks for uses of the keyword not instead of !.

Example:

# bad - parentheses are required because of op precedence
x = (not something)

# good
x = !something

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

          File.basename(JekyllRake::Utils.slugify(@title)) + "-" + i.to_s +
Severity: Minor
Found in lib/jekyll_rake/post.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

      (date != "" and date != "nil" and not date.nil?) ? date : Time.new.strftime("%Y-%m-%d %H:%M:%S %Z")
Severity: Minor
Found in lib/jekyll_rake/post.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

      puts "DATE and CATEGORY are optional"
Severity: Minor
Found in lib/jekyll_rake/post.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"

Align the operands of an expression in an assignment spanning multiple lines.
Open

          $post_ext
Severity: Minor
Found in lib/jekyll_rake/post.rb by rubocop

This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

There are no issues that match your filters.

Category
Status