FarmBot/OpenFarm

View on GitHub
spec/mutations/gardens/update_gardens_spec.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

describe Gardens::UpdateGarden do
  let(:mutation) { Gardens::UpdateGarden }

  let(:garden) { FactoryBot.create(:garden) }

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.

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

  it 'deletes images marked for deletion' do
    VCR.use_cassette('mutations/gardens/update_garden') do
      image_hash = [{ image_url: 'http://i.imgur.com/2haLt4J.jpg' }]

      image_params = params.merge(images: image_hash)
Severity: Minor
Found in spec/mutations/gardens/update_gardens_spec.rb and 1 other location - About 50 mins to fix
spec/mutations/stages/update_stages_spec.rb on lines 84..97

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

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

  it 'updates a garden image via URL' do
    VCR.use_cassette('mutations/gardens/update_garden') do
      image_hash = {
        image_url: 'http://i.imgur.com/2haLt4J.jpg'
      }
Severity: Minor
Found in spec/mutations/gardens/update_gardens_spec.rb and 2 other locations - About 30 mins to fix
spec/mutations/stages/create_stages_spec.rb on lines 24..32
spec/mutations/stages/update_stages_spec.rb on lines 24..32

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

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

Identical blocks of code found in 6 locations. Consider refactoring.
Open

  it 'disallows phony URLs' do
    image_hash = {
      image_url: 'iWroteThisWrong.net/2haLt4J.jpg'
    }
    image_params = params.merge(images: [image_hash])
Severity: Major
Found in spec/mutations/gardens/update_gardens_spec.rb and 5 other locations - About 30 mins to fix
spec/mutations/crops/update_crop_spec.rb on lines 46..53
spec/mutations/stage_actions/create_stage_actions_spec.rb on lines 36..43
spec/mutations/stage_actions/update_stage_actions_spec.rb on lines 38..45
spec/mutations/stages/create_stages_spec.rb on lines 36..43
spec/mutations/stages/update_stages_spec.rb on lines 36..46

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

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

Line is too long. [265/120]
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

  • ArgumentAlignment
  • BlockAlignment
  • BlockDelimiters
  • BlockEndNewline
  • ClosingParenthesisIndentation
  • FirstArgumentIndentation
  • FirstArrayElementIndentation
  • FirstHashElementIndentation
  • FirstParameterIndentation
  • HashAlignment
  • IndentationWidth
  • MultilineArrayLineBreaks
  • MultilineBlockLayout
  • MultilineHashBraceLayout
  • MultilineHashKeyLineBreaks
  • MultilineMethodArgumentLineBreaks
  • ParameterAlignment

Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

Example:

# bad
{foo: "0000000000", bar: "0000000000", baz: "0000000000"}

# good
{foo: "0000000000",
bar: "0000000000", baz: "0000000000"}

# good (with recommended cops enabled)
{
  foo: "0000000000",
  bar: "0000000000",
  baz: "0000000000",
}

Space inside { missing.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space (default)

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }
foo = { { a: 1 } => { b: { c: 2 } } }

# good
h = { a: { b: 2 }}
foo = {{ a: 1 } => { b: { c: 2 }}}

Example: EnforcedStyleForEmptyBraces: no_space (default)

# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces do not contain spaces.

# bad
foo = { }
bar = {    }

# good
foo = {}
bar = {}

Example: EnforcedStyleForEmptyBraces: space

# The `space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces contain space.

# bad
foo = {}

# good
foo = { }
foo = {  }
foo = {     }

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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"

Surrounding space missing for operator =>.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that operators have space around them, except for ** which should or shouldn't have surrounding space depending on configuration.

This cop has AllowForAlignment option. When true, allows most uses of extra spacing if the intent is to align with an operator on the previous or next line, not counting empty lines or comment lines.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4

Example: AllowForAlignment: true (default)

# good
{
  1 =>  2,
  11 => 3
}

Example: AllowForAlignment: false

# bad
{
  1 =>  2,
  11 => 3
}

Example: EnforcedStyleForExponentOperator: no_space (default)

# bad
a ** b

# good
a**b

Example: EnforcedStyleForExponentOperator: space

# bad
a**b

# good
a ** b

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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"

Surrounding space missing for operator =>.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that operators have space around them, except for ** which should or shouldn't have surrounding space depending on configuration.

This cop has AllowForAlignment option. When true, allows most uses of extra spacing if the intent is to align with an operator on the previous or next line, not counting empty lines or comment lines.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4

Example: AllowForAlignment: true (default)

# good
{
  1 =>  2,
  11 => 3
}

Example: AllowForAlignment: false

# bad
{
  1 =>  2,
  11 => 3
}

Example: EnforcedStyleForExponentOperator: no_space (default)

# bad
a ** b

# good
a**b

Example: EnforcedStyleForExponentOperator: space

# bad
a**b

# good
a ** b

Surrounding space missing for operator =>.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that operators have space around them, except for ** which should or shouldn't have surrounding space depending on configuration.

This cop has AllowForAlignment option. When true, allows most uses of extra spacing if the intent is to align with an operator on the previous or next line, not counting empty lines or comment lines.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4

Example: AllowForAlignment: true (default)

# good
{
  1 =>  2,
  11 => 3
}

Example: AllowForAlignment: false

# bad
{
  1 =>  2,
  11 => 3
}

Example: EnforcedStyleForExponentOperator: no_space (default)

# bad
a ** b

# good
a**b

Example: EnforcedStyleForExponentOperator: space

# bad
a**b

# good
a ** b

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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"

Indent the right brace the same as the start of the line where the left brace is.
Open

      }

This cop checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the HashAlignment cop.

By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.

Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.

This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:

Example: EnforcedStyle: specialinsideparentheses (default)

# The `special_inside_parentheses` style enforces that the first key
# in a hash literal where the opening brace and the first key are on
# separate lines is indented one step (two spaces) more than the
# position inside the opening parentheses.

# bad
hash = {
  key: :value
}
and_in_a_method_call({
  no: :difference
                     })

# good
special_inside_parentheses
hash = {
  key: :value
}
but_in_a_method_call({
                       its_like: :this
                     })

Example: EnforcedStyle: consistent

# The `consistent` style enforces that the first key in a hash
# literal where the opening brace and the first key are on
# separate lines is indented the same as a hash literal which is not
# defined inside a method call.

# bad
hash = {
  key: :value
}
but_in_a_method_call({
                       its_like: :this
                      })

# good
hash = {
  key: :value
}
and_in_a_method_call({
  no: :difference
})

Example: EnforcedStyle: align_braces

# The `align_brackets` style enforces that the opening and closing
# braces are indented to the same position.

# bad
and_now_for_something = {
                          completely: :different
}

# good
and_now_for_something = {
                          completely: :different
                        }

Space inside } missing.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space (default)

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }
foo = { { a: 1 } => { b: { c: 2 } } }

# good
h = { a: { b: 2 }}
foo = {{ a: 1 } => { b: { c: 2 }}}

Example: EnforcedStyleForEmptyBraces: no_space (default)

# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces do not contain spaces.

# bad
foo = { }
bar = {    }

# good
foo = {}
bar = {}

Example: EnforcedStyleForEmptyBraces: space

# The `space` EnforcedStyleForEmptyBraces style enforces that
# empty hash braces contain space.

# bad
foo = {}

# good
foo = { }
foo = {  }
foo = {     }

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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"

Surrounding space missing for operator =>.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that operators have space around them, except for ** which should or shouldn't have surrounding space depending on configuration.

This cop has AllowForAlignment option. When true, allows most uses of extra spacing if the intent is to align with an operator on the previous or next line, not counting empty lines or comment lines.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4

Example: AllowForAlignment: true (default)

# good
{
  1 =>  2,
  11 => 3
}

Example: AllowForAlignment: false

# bad
{
  1 =>  2,
  11 => 3
}

Example: EnforcedStyleForExponentOperator: no_space (default)

# bad
a ** b

# good
a**b

Example: EnforcedStyleForExponentOperator: space

# bad
a**b

# good
a ** b

Surrounding space missing for operator =>.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that operators have space around them, except for ** which should or shouldn't have surrounding space depending on configuration.

This cop has AllowForAlignment option. When true, allows most uses of extra spacing if the intent is to align with an operator on the previous or next line, not counting empty lines or comment lines.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4

Example: AllowForAlignment: true (default)

# good
{
  1 =>  2,
  11 => 3
}

Example: AllowForAlignment: false

# bad
{
  1 =>  2,
  11 => 3
}

Example: EnforcedStyleForExponentOperator: no_space (default)

# bad
a ** b

# good
a**b

Example: EnforcedStyleForExponentOperator: space

# bad
a**b

# good
a ** b

Missing frozen string literal comment.
Open

require 'spec_helper'

This cop is designed to help you transition from mutable string literals to frozen string literals. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in future Ruby. The comment will be added below a shebang and encoding comment.

Note that the cop will ignore files where the comment exists but is set to false instead of true.

Example: EnforcedStyle: always (default)

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

# good
# frozen_string_literal: false

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Example: EnforcedStyle: always_true

# The `always_true` style enforces that the frozen string literal
# comment is set to `true`. This is a stricter option than `always`
# and forces projects to use frozen string literals.
# bad
# frozen_string_literal: false

module Baz
  # ...
end

# bad
module Baz
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Prefer to_s over string interpolation.
Open

      id: "#{garden._id}",

This cop checks for strings that are just an interpolated expression.

Example:

# bad
"#{@var}"

# good
@var.to_s

# good if @var is already a String
@var

Prefer to_s over string interpolation.
Open

      id: "#{garden._id}",

This cop checks for strings that are just an interpolated expression.

Example:

# bad
"#{@var}"

# good
@var.to_s

# good if @var is already a String
@var

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

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"

Surrounding space missing for operator =>.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that operators have space around them, except for ** which should or shouldn't have surrounding space depending on configuration.

This cop has AllowForAlignment option. When true, allows most uses of extra spacing if the intent is to align with an operator on the previous or next line, not counting empty lines or comment lines.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4

Example: AllowForAlignment: true (default)

# good
{
  1 =>  2,
  11 => 3
}

Example: AllowForAlignment: false

# bad
{
  1 =>  2,
  11 => 3
}

Example: EnforcedStyleForExponentOperator: no_space (default)

# bad
a ** b

# good
a**b

Example: EnforcedStyleForExponentOperator: space

# bad
a**b

# good
a ** b

Surrounding space missing for operator =>.
Open

    attributes = {"name"=>"The Hanoi Balcony", "location"=>"Inside", "description"=>"We created this garden automatically to get\nyou started. You can edit it to better suit\nyour needs!", "type"=>"Inside", "average_sun"=>"Full Sun", "soil_type"=>"Loam", "ph"=>7.5}

Checks that operators have space around them, except for ** which should or shouldn't have surrounding space depending on configuration.

This cop has AllowForAlignment option. When true, allows most uses of extra spacing if the intent is to align with an operator on the previous or next line, not counting empty lines or comment lines.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4

Example: AllowForAlignment: true (default)

# good
{
  1 =>  2,
  11 => 3
}

Example: AllowForAlignment: false

# bad
{
  1 =>  2,
  11 => 3
}

Example: EnforcedStyleForExponentOperator: no_space (default)

# bad
a ** b

# good
a**b

Example: EnforcedStyleForExponentOperator: space

# bad
a**b

# good
a ** b

There are no issues that match your filters.

Category
Status