FarmBot/OpenFarm

View on GitHub
app/controllers/confirmations_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

  def show
    token = params.require(:confirmation_token).encode!(
      "UTF-8",
      "binary",
      invalid: :replace,

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.

Method show has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    token = params.require(:confirmation_token).encode!(
      "UTF-8",
      "binary",
      invalid: :replace,
Severity: Minor
Found in app/controllers/confirmations_controller.rb - About 1 hr to fix

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

      def show
        token = params.require(:confirmation_token).encode!(
          "UTF-8",
          "binary",
          invalid: :replace,
    Severity: Minor
    Found in app/controllers/confirmations_controller.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

    Assignment Branch Condition size for show is too high. [<4, 30, 5> 30.68/15]
    Open

      def show
        token = params.require(:confirmation_token).encode!(
          "UTF-8",
          "binary",
          invalid: :replace,

    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 and https://en.wikipedia.org/wiki/ABC_Software_Metric.

    Missing top-level class documentation comment.
    Open

    class ConfirmationsController < Devise::ConfirmationsController

    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, constant definitions or constant visibility declarations.

    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
    
    module Math
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end
    
    # allowed
      # Class without body
      class Person
      end
    
      # Namespace - A namespace can be a class or a module
      # Containing a class
      module Namespace
        # Description/Explanation of Person class
        class Person
          # ...
        end
      end
    
      # Containing constant visibility declaration
      module Namespace
        class Private
        end
    
        private_constant :Private
      end
    
      # Containing constant definition
      module Namespace
        Public = Class.new
      end

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

          replace: "",

    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"

    Avoid using {...} for multi-line blocks.
    Open

          ) {

    Check for uses of braces or do/end around single line or multi-line blocks.

    Example: EnforcedStyle: linecountbased (default)

    # bad - single line block
    items.each do |item| item / 5 end
    
    # good - single line block
    items.each { |item| item / 5 }
    
    # bad - multi-line block
    things.map { |thing|
      something = thing.some_method
      process(something)
    }
    
    # good - multi-line block
    things.map do |thing|
      something = thing.some_method
      process(something)
    end

    Example: EnforcedStyle: semantic

    # Prefer `do...end` over `{...}` for procedural blocks.
    
    # return value is used/assigned
    # bad
    foo = map do |x|
      x
    end
    puts (map do |x|
      x
    end)
    
    # return value is not used out of scope
    # good
    map do |x|
      x
    end
    
    # Prefer `{...}` over `do...end` for functional blocks.
    
    # return value is not used out of scope
    # bad
    each { |x|
      x
    }
    
    # return value is used/assigned
    # good
    foo = map { |x|
      x
    }
    map { |x|
      x
    }.inspect
    
    # The AllowBracesOnProceduralOneLiners option is ignored unless the
    # EnforcedStyle is set to `semantic`. If so:
    
    # If the AllowBracesOnProceduralOneLiners option is unspecified, or
    # set to `false` or any other falsey value, then semantic purity is
    # maintained, so one-line procedural blocks must use do-end, not
    # braces.
    
    # bad
    collection.each { |element| puts element }
    
    # good
    collection.each do |element| puts element end
    
    # If the AllowBracesOnProceduralOneLiners option is set to `true`, or
    # any other truthy value, then one-line procedural blocks may use
    # either style. (There is no setting for requiring braces on them.)
    
    # good
    collection.each { |element| puts element }
    
    # also good
    collection.each do |element| puts element end

    Example: EnforcedStyle: bracesforchaining

    # bad
    words.each do |word|
      word.flip.flop
    end.join("-")
    
    # good
    words.each { |word|
      word.flip.flop
    }.join("-")

    Example: EnforcedStyle: always_braces

    # bad
    words.each do |word|
      word.flip.flop
    end
    
    # good
    words.each { |word|
      word.flip.flop
    }

    Example: BracesRequiredMethods: ['sig']

    # Methods listed in the BracesRequiredMethods list, such as 'sig'
    # in this example, will require `{...}` braces. This option takes
    # precedence over all other configurations except IgnoredMethods.
    
    # bad
    sig do
      params(
        foo: string,
      ).void
    end
    def bar(foo)
      puts foo
    end
    
    # good
    sig {
      params(
        foo: string,
      ).void
    }
    def bar(foo)
      puts foo
    end

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

            render "/devise/confirmations/new"

    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

            type: "Outside",

    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

                                  action: "show",

    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"

    Avoid comma after the last parameter of a method call.
    Open

            soil_type: "Loam",

    This cop checks for trailing comma in argument lists. The supported styles are:

    • consistent_comma: Requires a comma after the last argument, for all parenthesized method calls with arguments.
    • comma: Requires a comma after the last argument, but only for parenthesized method calls where each argument is on its own line.
    • no_comma: Requires that there is no comma after the last argument.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # good
    method(
      1, 2,
      3,
    )
    
    # good
    method(
      1, 2, 3,
    )
    
    # good
    method(
      1,
      2,
    )

    Example: EnforcedStyleForMultiline: comma

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # bad
    method(
      1, 2,
      3,
    )
    
    # good
    method(
      1, 2,
      3
    )
    
    # bad
    method(
      1, 2, 3,
    )
    
    # good
    method(
      1, 2, 3
    )
    
    # good
    method(
      1,
      2,
    )

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # good
    method(
      1,
      2
    )

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

            average_sun: "Full Sun",

    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

              redirect_to url_for(controller: "users",

    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"

    Avoid comma after the last parameter of a method call.
    Open

          replace: "",

    This cop checks for trailing comma in argument lists. The supported styles are:

    • consistent_comma: Requires a comma after the last argument, for all parenthesized method calls with arguments.
    • comma: Requires a comma after the last argument, but only for parenthesized method calls where each argument is on its own line.
    • no_comma: Requires that there is no comma after the last argument.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # good
    method(
      1, 2,
      3,
    )
    
    # good
    method(
      1, 2, 3,
    )
    
    # good
    method(
      1,
      2,
    )

    Example: EnforcedStyleForMultiline: comma

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # bad
    method(
      1, 2,
      3,
    )
    
    # good
    method(
      1, 2,
      3
    )
    
    # bad
    method(
      1, 2, 3,
    )
    
    # good
    method(
      1, 2, 3
    )
    
    # good
    method(
      1,
      2,
    )

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # good
    method(
      1,
      2
    )

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

            name: I18n.t("registrations.your_first_garden"),

    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

            description: I18n.t("registrations.generated_this_garden"),

    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

              redirect_to url_for(controller: "users",

    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

            soil_type: "Loam",

    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

          "binary",

    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 frozen string literal comment.
    Open

    class ConfirmationsController < Devise::ConfirmationsController

    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 single-quoted strings when you don't need string interpolation or special symbols.
    Open

          "UTF-8",

    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

                                  action: "finish")

    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"

    Avoid comma after the last parameter of a method call.
    Open

            status: :unprocessable_entity,

    This cop checks for trailing comma in argument lists. The supported styles are:

    • consistent_comma: Requires a comma after the last argument, for all parenthesized method calls with arguments.
    • comma: Requires a comma after the last argument, but only for parenthesized method calls where each argument is on its own line.
    • no_comma: Requires that there is no comma after the last argument.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # good
    method(
      1, 2,
      3,
    )
    
    # good
    method(
      1, 2, 3,
    )
    
    # good
    method(
      1,
      2,
    )

    Example: EnforcedStyleForMultiline: comma

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # bad
    method(
      1, 2,
      3,
    )
    
    # good
    method(
      1, 2,
      3
    )
    
    # bad
    method(
      1, 2, 3,
    )
    
    # good
    method(
      1, 2, 3
    )
    
    # good
    method(
      1,
      2,
    )

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    method(1, 2,)
    
    # good
    method(1, 2)
    
    # good
    method(
      1,
      2
    )

    There are no issues that match your filters.

    Category
    Status