angelakuo/citydogshare

View on GitHub
app/controllers/dogs_controller.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Possible SQL injection
Open

    if !Dog.exists?(id)
Severity: Critical
Found in app/controllers/dogs_controller.rb by brakeman

Injection is #1 on the 2013 OWASP Top Ten web security risks. SQL injection is when a user is able to manipulate a value which is used unsafely inside a SQL query. This can lead to data leaks, data loss, elevation of privilege, and other unpleasant outcomes.

Brakeman focuses on ActiveRecord methods dealing with building SQL statements.

A basic (Rails 2.x) example looks like this:

User.first(:conditions => "username = '#{params[:username]}'")

Brakeman would produce a warning like this:

Possible SQL injection near line 30: User.first(:conditions => ("username = '#{params[:username]}'"))

The safe way to do this query is to use a parameterized query:

User.first(:conditions => ["username = ?", params[:username]])

Brakeman also understands the new Rails 3.x way of doing things (and local variables and concatenation):

username = params[:user][:name].downcase
password = params[:user][:password]

User.first.where("username = '" + username + "' AND password = '" + password + "'")

This results in this kind of warning:

Possible SQL injection near line 37:
User.first.where((((("username = '" + params[:user][:name].downcase) + "' AND password = '") + params[:user][:password]) + "'"))

See the Ruby Security Guide for more information and Rails-SQLi.org for many examples of SQL injection in Rails.

Class has too many lines. [186/100]
Open

class DogsController < ApplicationController

  require 'dog_form_filler'

  before_filter :current_user
Severity: Minor
Found in app/controllers/dogs_controller.rb by rubocop

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

Assignment Branch Condition size for update is too high. [25.67/15]
Open

  def update
    @form_filler = DogViewHelper.new(nil, nil, false)
    @dog = Dog.find(params[:id])
    @pictures = @dog.pictures
    if not @is_admin and @dog.user != @current_user
Severity: Minor
Found in app/controllers/dogs_controller.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

Class DogsController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class DogsController < ApplicationController

  require 'dog_form_filler'

  before_filter :current_user
Severity: Minor
Found in app/controllers/dogs_controller.rb - About 2 hrs to fix

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

      def update
        @form_filler = DogViewHelper.new(nil, nil, false)
        @dog = Dog.find(params[:id])
        @pictures = @dog.pictures
        if not @is_admin and @dog.user != @current_user
    Severity: Minor
    Found in app/controllers/dogs_controller.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.

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

      def info
        id = params[:id]
        if !Dog.exists?(id)
          render :json => {
            "success" => false,
    Severity: Minor
    Found in app/controllers/dogs_controller.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 attributes_list is too high. [19.44/15]
    Open

      def attributes_list(dog_attributes)
        ## Return hash with new dog values to create new dog/update existing dog
        new_attrs = {
          :mixes => get_mix_array(dog_attributes['mixes']),
          :size => dog_attributes['size'] && dog_attributes['size'].length != 0 ? Size.find(dog_attributes['size']): nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.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 all_info is too high. [18.87/15]
    Open

      def all_info
        filtered_dogs_hash = Dog.all.select { |dog|
          valid_dog = true
          if params[:available] == "true" && !dog.available then valid_dog = false end
          if params[:available] == "false" && dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.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 dog_params is too high. [17.06/15]
    Open

      def dog_params
        params.require(:dog).keys.each do |key|
          if params[:dog][key].kind_of?(Array)
            params[:dog][key] = purge_param(params[:dog][key])
          end
    Severity: Minor
    Found in app/controllers/dogs_controller.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 delete_checked_pictures is too high. [16.97/15]
    Open

      def delete_checked_pictures
        activated_ids = params[:activated].collect {|id| id.to_i} if params[:activated]
        seen_ids = params[:seen].collect {|id| id.to_i} if params[:seen]
    
        if activated_ids
    Severity: Minor
    Found in app/controllers/dogs_controller.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 index is too high. [16.67/15]
    Open

      def index
        ip_zipcode = get_ip_address_zipcode
        @form_filler = DogViewHelper.new(current_user, ip_zipcode, true)
        @form_filler.update_values(params, ip_zipcode, current_user)
        @dogs = Dog.filter_by(@form_filler.values).uniq
    Severity: Minor
    Found in app/controllers/dogs_controller.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. [11/10]
    Open

      def all_info
        filtered_dogs_hash = Dog.all.select { |dog|
          valid_dog = true
          if params[:available] == "true" && !dog.available then valid_dog = false end
          if params[:available] == "false" && dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.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 create is too high. [15.56/15]
    Open

      def create
        @dog = Dog.new(attributes_list(dog_params))
        @dog.user_id = current_user.id
        if @dog.save      
          add_multiple_pictures(@dog)
    Severity: Minor
    Found in app/controllers/dogs_controller.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 all_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def all_info
        filtered_dogs_hash = Dog.all.select { |dog|
          valid_dog = true
          if params[:available] == "true" && !dog.available then valid_dog = false end
          if params[:available] == "false" && dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.rb - About 35 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 delete_checked_pictures has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def delete_checked_pictures
        activated_ids = params[:activated].collect {|id| id.to_i} if params[:activated]
        seen_ids = params[:seen].collect {|id| id.to_i} if params[:seen]
    
        if activated_ids
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Use each_key instead of keys.each.
    Open

        params.require(:dog).keys.each do |key|
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks for uses of each_key and each_value Hash methods.

    Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

    Example:

    # bad
    hash.keys.each { |k| p k }
    hash.values.each { |v| p v }
    hash.each { |k, _v| p k }
    hash.each { |_k, v| p v }
    
    # good
    hash.each_key { |k| p k }
    hash.each_value { |v| p v }

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

      def info
        id = params[:id]
        if !Dog.exists?(id)
          render :json => {
            "success" => false,
    Severity: Minor
    Found in app/controllers/dogs_controller.rb and 1 other location - About 35 mins to fix
    app/controllers/users_controller.rb on lines 39..50

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

    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

    Space missing to the left of {.
    Open

        @dogs.all.collect{|dog| dog.address}
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have a space before the opening brace depending on configuration.

    Example:

    # bad
    foo.map{ |a|
      a.bar.to_s
    }
    
    # good
    foo.map { |a|
      a.bar.to_s
    }

    Space inside } missing.
    Open

        :motto, :fixed, :health, :comments, :contact, :availability, {:mixes => []}, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Space inside { missing.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Trailing whitespace detected.
    Open

      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [81/80]
    Open

        :motto, :fixed, :health, :comments, :contact, :availability, {:mixes => []}, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [148/80]
    Open

          if Mix.all_values.include?(val) or Personality.all_values.include?(val) or Like.all_values.include?(val) or Bark.all_values.include?(val) then
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Do not prefix reader method names with get_.
    Open

      def get_zipcode_from_dogs
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Missing top-level class documentation comment.
    Open

    class DogsController < ApplicationController
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

        if attributes[trait] != nil
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Use the new Ruby 1.9 hash syntax.
    Open

          render :json => { 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use the new Ruby 1.9 hash syntax.
    Open

          :barks => get_attribute_array(dog_attributes, 'barks'),
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use ! instead of not.
    Open

        if not @is_admin and @dog.user != @current_user
    Severity: Minor
    Found in app/controllers/dogs_controller.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

          if params[:available] == "false" && dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.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

          flash[:notice] = "Please update your zipcode to add a dog. "
    Severity: Minor
    Found in app/controllers/dogs_controller.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"

    Pass &:to_i as an argument to collect instead of a block.
    Open

        seen_ids = params[:seen].collect {|id| id.to_i} if params[:seen]
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use symbols as procs when possible.

    Example:

    # bad
    something.map { |s| s.upcase }
    
    # good
    something.map(&:upcase)

    Space missing inside }.
    Open

        seen_ids = params[:seen].collect {|id| id.to_i} if params[:seen]
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Space inside { missing.
    Open

        :motto, :fixed, :health, :comments, :contact, :availability, {:mixes => []}, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Space inside } missing.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Trailing whitespace detected.
    Open

        unless current_user.zipcode != nil and current_user.zipcode != "" 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [97/80]
    Open

        @starred_dogs = @current_user && @current_user.starred_dogs ? @current_user.starred_dogs : []
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Prefer Object#is_a? over Object#kind_of?.
    Open

          if params[:dog][key].kind_of?(Array)
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop enforces consistent use of Object#is_a? or Object#kind_of?.

    Example: EnforcedStyle: is_a? (default)

    # bad
    var.kind_of?(Date)
    var.kind_of?(Integer)
    
    # good
    var.is_a?(Date)
    var.is_a?(Integer)

    Example: EnforcedStyle: kind_of?

    # bad
    var.is_a?(Time)
    var.is_a?(String)
    
    # good
    var.kind_of?(Time)
    var.kind_of?(String)

    Use the new Ruby 1.9 hash syntax.
    Open

          :message => filtered_dogs_hash.size.to_s + " dog(s) found",
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use the new Ruby 1.9 hash syntax.
    Open

          :likes => get_attribute_array(dog_attributes, 'likes'),
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

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

          :message => filtered_dogs_hash.size.to_s + " dog(s) found",
    Severity: Minor
    Found in app/controllers/dogs_controller.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 parameters of a method call if they span more than one line.
    Open

        {:likes =>[]}, :energy_level, :size, :photo, :latitude, :longitude, :video, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Here we check if the parameters on a multi-line method call or definition are aligned.

    Example: EnforcedStyle: withfirstparameter (default)

    # good
    
    foo :bar,
        :baz
    
    # bad
    
    foo :bar,
      :baz

    Example: EnforcedStyle: withfixedindentation

    # good
    
    foo :bar,
      :baz
    
    # bad
    
    foo :bar,
        :baz

    Space missing inside }.
    Open

        @zipcodes.each{|word| wf[word] += 1}
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Trailing whitespace detected.
    Open

        params.require(:dog).permit(:name, :image, :dob, :gender, :description, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use the new Ruby 1.9 hash syntax.
    Open

        :motto, :fixed, :health, :comments, :contact, :availability, {:mixes => []}, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

          if params[:available] == "false" && dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Extra empty line detected at class body beginning.
    Open

    
      require 'dog_form_filler'
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cops checks if empty lines around the bodies of classes match the configuration.

    Example: EnforcedStyle: empty_lines

    # good
    
    class Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    class Foo
      class Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    class Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    class Foo
      def bar
        # ...
      end
    end

    Space inside { missing.
    Open

        {:likes =>[]}, :energy_level, :size, :photo, :latitude, :longitude, :video, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Trailing whitespace detected.
    Open

        if @dog.save      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

        {:likes =>[]}, :energy_level, :size, :photo, :latitude, :longitude, :video, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [87/80]
    Open

      # Removes the default "" values and any invalid value the user my try to send through
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use the new Ruby 1.9 hash syntax.
    Open

          :mixes => get_mix_array(dog_attributes['mixes']),
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

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

        unless current_user.zipcode != nil and current_user.zipcode != "" 
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Space missing to the left of {.
    Open

        mix_arr.blank? ? [] : mix_arr.map{ |m| Mix.find_by_value(m) }
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have a space before the opening brace depending on configuration.

    Example:

    # bad
    foo.map{ |a|
      a.bar.to_s
    }
    
    # good
    foo.map { |a|
      a.bar.to_s
    }

    Trailing whitespace detected.
    Open

          render :json => { 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

          seen_ids.each do |id|          
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use the new Ruby 1.9 hash syntax.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use the new Ruby 1.9 hash syntax.
    Open

          :personalities => get_attribute_array(dog_attributes, 'personalities'),
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Avoid multi-line chains of blocks.
    Open

        }.map { |dog| { :name => dog.name, :id => dog.id } }
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks for chaining of a block after another block that spans multiple lines.

    Example:

    Thread.list.find_all do |t|
      t.alive?
    end.map do |t|
      t.object_id
    end

    Align the parameters of a method call if they span more than one line.
    Open

        :motto, :fixed, :health, :comments, :contact, :availability, {:mixes => []}, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Here we check if the parameters on a multi-line method call or definition are aligned.

    Example: EnforcedStyle: withfirstparameter (default)

    # good
    
    foo :bar,
        :baz
    
    # bad
    
    foo :bar,
      :baz

    Example: EnforcedStyle: withfixedindentation

    # good
    
    foo :bar,
      :baz
    
    # bad
    
    foo :bar,
        :baz

    Surrounding space missing for operator :.
    Open

          :size => dog_attributes['size'] && dog_attributes['size'].length != 0 ? Size.find(dog_attributes['size']): nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that operators have space around them, except for ** which should not have surrounding space.

    Example:

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

    Space missing inside }.
    Open

        @dogs.all.collect{|dog| dog.address}
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Space inside } missing.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Use && instead of and.
    Open

        if not @is_admin and @dog.user != @current_user
    Severity: Minor
    Found in app/controllers/dogs_controller.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 or.
    Open

          if Mix.all_values.include?(val) or Personality.all_values.include?(val) or Like.all_values.include?(val) or Bark.all_values.include?(val) then
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

          if params[:available] == "true" && !dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

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

            "success" => true,
    Severity: Minor
    Found in app/controllers/dogs_controller.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

            "dog" => @dog.to_json
    Severity: Minor
    Found in app/controllers/dogs_controller.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

      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [118/80]
    Open

          :size => dog_attributes['size'] && dog_attributes['size'].length != 0 ? Size.find(dog_attributes['size']): nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

        if params[:images]        
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

        if activated_ids
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Use the new Ruby 1.9 hash syntax.
    Open

        render :json => {
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use the new Ruby 1.9 hash syntax.
    Open

        {:likes =>[]}, :energy_level, :size, :photo, :latitude, :longitude, :video, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Trailing whitespace detected.
    Open

        :motto, :fixed, :health, :comments, :contact, :availability, {:mixes => []}, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Space between { and | missing.
    Open

        seen_ids = params[:seen].collect {|id| id.to_i} if params[:seen]
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Line is too long. [99/80]
    Open

      # A function to get the attribures in the proper format, has helper functions used directly below
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

          :size => dog_attributes['size'] && dog_attributes['size'].length != 0 ? Size.find(dog_attributes['size']): nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

          :energy_level => dog_attributes['energy_level'] && dog_attributes['energy_level'].length != 0 ? EnergyLevel.find(dog_attributes['energy_level']) : nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use the new Ruby 1.9 hash syntax.
    Open

          render :json => {
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use the new Ruby 1.9 hash syntax.
    Open

          :dob => get_birthday(dog_attributes) }
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Space missing to the left of {.
    Open

        @zipcodes.each{|word| wf[word] += 1}
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have a space before the opening brace depending on configuration.

    Example:

    # bad
    foo.map{ |a|
      a.bar.to_s
    }
    
    # good
    foo.map { |a|
      a.bar.to_s
    }

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use the new Ruby 1.9 hash syntax.
    Open

          :size => dog_attributes['size'] && dog_attributes['size'].length != 0 ? Size.find(dog_attributes['size']): nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

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

            "success" => false,
    Severity: Minor
    Found in app/controllers/dogs_controller.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

            "message" => "Dog not found"
    Severity: Minor
    Found in app/controllers/dogs_controller.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

          if params[:available] == "true" && !dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.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

        unless current_user.zipcode != nil and current_user.zipcode != "" 
    Severity: Minor
    Found in app/controllers/dogs_controller.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 !empty? instead of length != 0.
    Open

          :size => dog_attributes['size'] && dog_attributes['size'].length != 0 ? Size.find(dog_attributes['size']): nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

    Example:

    # bad
    [1, 2, 3].length == 0
    0 == "foobar".length
    array.length < 1
    {a: 1, b: 2}.length != 0
    string.length > 0
    hash.size > 0
    
    # good
    [1, 2, 3].empty?
    "foobar".empty?
    array.empty?
    !{a: 1, b: 2}.empty?
    !string.empty?
    !hash.empty?

    Closing hash brace must be on the line after the last hash element when opening brace is on a separate line from the first hash element.
    Open

          :dob => get_birthday(dog_attributes) }
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks that the closing brace in a hash literal is either on the same line as the last hash element, or a new line.

    When using the symmetrical (default) style:

    If a hash's opening brace is on the same line as the first element of the hash, then the closing brace should be on the same line as the last element of the hash.

    If a hash's opening brace is on the line above the first element of the hash, then the closing brace should be on the line below the last element of the hash.

    When using the new_line style:

    The closing brace of a multi-line hash literal must be on the line after the last element of the hash.

    When using the same_line style:

    The closing brace of a multi-line hash literal must be on the same line as the last element of the hash.

    Example: EnforcedStyle: symmetrical (default)

    # bad
      { a: 1,
        b: 2
      }
      # bad
      {
        a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2 }
    
      # good
      {
        a: 1,
        b: 2
      }

    Example: EnforcedStyle: new_line

    # bad
      {
        a: 1,
        b: 2 }
    
      # bad
      { a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2
      }
    
      # good
      {
        a: 1,
        b: 2
      }

    Example: EnforcedStyle: same_line

    # bad
      { a: 1,
        b: 2
      }
    
      # bad
      {
        a: 1,
        b: 2
      }
    
      # good
      {
        a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2 }

    Space between { and | missing.
    Open

        @dogs.all.collect{|dog| dog.address}
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Space inside } missing.
    Open

        {:likes =>[]}, :energy_level, :size, :photo, :latitude, :longitude, :video, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Use snake_case for variable names.
    Open

      def add_multiple_pictures(myDog)
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    fooBar = 1
    
    # good
    foo_bar = 1

    Example: EnforcedStyle: camelCase

    # bad
    foo_bar = 1
    
    # good
    fooBar = 1

    Redundant curly braces around a hash parameter.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

    Example: EnforcedStyle: braces

    # The `braces` style enforces braces around all method
    # parameters that are hashes.
    
    # bad
    some_method(x, y, a: 1, b: 2)
    
    # good
    some_method(x, y, {a: 1, b: 2})

    Example: EnforcedStyle: no_braces (default)

    # The `no_braces` style checks that the last parameter doesn't
    # have braces around it.
    
    # bad
    some_method(x, y, {a: 1, b: 2})
    
    # good
    some_method(x, y, a: 1, b: 2)

    Example: EnforcedStyle: context_dependent

    # The `context_dependent` style checks that the last parameter
    # doesn't have braces around it, but requires braces if the
    # second to last parameter is also a hash literal.
    
    # bad
    some_method(x, y, {a: 1, b: 2})
    some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
    
    # good
    some_method(x, y, a: 1, b: 2)
    some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

    Use the new Ruby 1.9 hash syntax.
    Open

        }.map { |dog| { :name => dog.name, :id => dog.id } }
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Do not use then for multi-line if.
    Open

          if Mix.all_values.include?(val) or Personality.all_values.include?(val) or Like.all_values.include?(val) or Bark.all_values.include?(val) then
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Space missing inside }.
    Open

        activated_ids = params[:activated].collect {|id| id.to_i} if params[:activated]
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Space inside { missing.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

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

    Example: EnforcedStyle: space

    # 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 } }
    
    # good
    h = { a: { b: 2 }}

    Trailing whitespace detected.
    Open

          redirect_to edit_dog_path(@dog.id) 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

      
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [82/80]
    Open

          if params[:available] == "true" && !dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Do not prefix reader method names with get_.
    Open

      def get_ip_address_zipcode
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Use && instead of and.
    Open

        unless current_user.zipcode != nil and current_user.zipcode != "" 
    Severity: Minor
    Found in app/controllers/dogs_controller.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 or.
    Open

          if Mix.all_values.include?(val) or Personality.all_values.include?(val) or Like.all_values.include?(val) or Bark.all_values.include?(val) then
    Severity: Minor
    Found in app/controllers/dogs_controller.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 the new Ruby 1.9 hash syntax.
    Open

        }.map { |dog| { :name => dog.name, :id => dog.id } }
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

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

            "message" => "Dog not found"
    Severity: Minor
    Found in app/controllers/dogs_controller.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"

    Surrounding space missing for operator =>.
    Open

        {:likes =>[]}, :energy_level, :size, :photo, :latitude, :longitude, :video, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that operators have space around them, except for ** which should not have surrounding space.

    Example:

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

    Trailing whitespace detected.
    Open

        if params[:images]        
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [82/80]
    Open

          if params[:available] == "false" && dog.available then valid_dog = false end
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Line is too long. [83/80]
    Open

        activated_ids = params[:activated].collect {|id| id.to_i} if params[:activated]
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Do not prefix reader method names with get_.
    Open

      def get_zipcode_counts
    Severity: Minor
    Found in app/controllers/dogs_controller.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

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

        filtered_dogs_hash = Dog.all.select { |dog|
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    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

    Example: EnforcedStyle: bracesforchaining

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

    Prefer {...} over do...end for single-line blocks.
    Open

        delete_params.each do |p| check_params.delete(p) end
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    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

    Example: EnforcedStyle: bracesforchaining

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

    Use the new Ruby 1.9 hash syntax.
    Open

          :success => true,
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use the new Ruby 1.9 hash syntax.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

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

            "message" => "Dog found",
    Severity: Minor
    Found in app/controllers/dogs_controller.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"

    Space between { and | missing.
    Open

        activated_ids = params[:activated].collect {|id| id.to_i} if params[:activated]
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Line is too long. [158/80]
    Open

          :energy_level => dog_attributes['energy_level'] && dog_attributes['energy_level'].length != 0 ? EnergyLevel.find(dog_attributes['energy_level']) : nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use && instead of and.
    Open

        if not @is_admin and @dog.user != @current_user
    Severity: Minor
    Found in app/controllers/dogs_controller.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 the new Ruby 1.9 hash syntax.
    Open

          :dogs => filtered_dogs_hash
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Use the new Ruby 1.9 hash syntax.
    Open

          :energy_level => dog_attributes['energy_level'] && dog_attributes['energy_level'].length != 0 ? EnergyLevel.find(dog_attributes['energy_level']) : nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

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

        if attributes[trait] != nil
    Severity: Minor
    Found in app/controllers/dogs_controller.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

        if not @is_admin and @dog.user != @current_user
    Severity: Minor
    Found in app/controllers/dogs_controller.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

    Pass &:address as an argument to collect instead of a block.
    Open

        @dogs.all.collect{|dog| dog.address}
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use symbols as procs when possible.

    Example:

    # bad
    something.map { |s| s.upcase }
    
    # good
    something.map(&:upcase)

    Use !empty? instead of length != 0.
    Open

          :energy_level => dog_attributes['energy_level'] && dog_attributes['energy_level'].length != 0 ? EnergyLevel.find(dog_attributes['energy_level']) : nil, 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

    Example:

    # bad
    [1, 2, 3].length == 0
    0 == "foobar".length
    array.length < 1
    {a: 1, b: 2}.length != 0
    string.length > 0
    hash.size > 0
    
    # good
    [1, 2, 3].empty?
    "foobar".empty?
    array.empty?
    !{a: 1, b: 2}.empty?
    !string.empty?
    !hash.empty?

    Align the parameters of a method call if they span more than one line.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Here we check if the parameters on a multi-line method call or definition are aligned.

    Example: EnforcedStyle: withfirstparameter (default)

    # good
    
    foo :bar,
        :baz
    
    # bad
    
    foo :bar,
      :baz

    Example: EnforcedStyle: withfixedindentation

    # good
    
    foo :bar,
      :baz
    
    # bad
    
    foo :bar,
        :baz

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Trailing whitespace detected.
    Open

        end  
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use ! instead of not.
    Open

        if not @is_admin and @dog.user != @current_user
    Severity: Minor
    Found in app/controllers/dogs_controller.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

            "message" => "Dog found",
    Severity: Minor
    Found in app/controllers/dogs_controller.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"

    Pass &:to_i as an argument to collect instead of a block.
    Open

        activated_ids = params[:activated].collect {|id| id.to_i} if params[:activated]
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use symbols as procs when possible.

    Example:

    # bad
    something.map { |s| s.upcase }
    
    # good
    something.map(&:upcase)

    Surrounding space missing for operator =>.
    Open

        :dob, {:personalities =>[]}, :chipped, :shots_to_date, {:barks => []})
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that operators have space around them, except for ** which should not have surrounding space.

    Example:

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

    Space between { and | missing.
    Open

        @zipcodes.each{|word| wf[word] += 1}
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Use && instead of and.
    Open

        if not @is_admin and @dog.user != @current_user
    Severity: Minor
    Found in app/controllers/dogs_controller.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 or.
    Open

          if Mix.all_values.include?(val) or Personality.all_values.include?(val) or Like.all_values.include?(val) or Bark.all_values.include?(val) then
    Severity: Minor
    Found in app/controllers/dogs_controller.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

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

          params[:images].each { |image|
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    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

    Example: EnforcedStyle: bracesforchaining

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

    Prefer Date or Time over DateTime.
    Open

        DateTime.new(year, 1, 1)
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks for uses of DateTime that should be replaced by Date or Time.

    Example:

    # bad - uses `DateTime` for current time
    DateTime.now
    
    # good - uses `Time` for current time
    Time.now
    
    # bad - uses `DateTime` for modern date
    DateTime.iso8601('2016-06-29')
    
    # good - uses `Date` for modern date
    Date.iso8601('2016-06-29')
    
    # good - uses `DateTime` with start argument for historical date
    DateTime.iso8601('1751-04-23', Date::ENGLAND)

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

        unless current_user.zipcode != nil and current_user.zipcode != "" 
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Redundant return detected.
    Open

          return []
    Severity: Minor
    Found in app/controllers/dogs_controller.rb by rubocop

    This cop checks for redundant return expressions.

    Example:

    def test
      return something
    end
    
    def test
      one
      two
      three
      return something
    end

    It should be extended to handle methods whose body is if/else or a case expression with a default branch.

    There are no issues that match your filters.

    Category
    Status