SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,636 of 12,636 total issues

Use 2 (not 1) spaces for indentation.
Open

     json.id babag.id

This cop checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

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

  json.imported_objects dataset_record.metadata["imported_objects"] if dataset_record.metadata["imported_objects"]

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 symbols instead of strings as hash keys.
Open

'generator'          => 'TaxonWorks',                    

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

Prefer symbols instead of strings as hash keys.
Open

'xmlns:nex'          => 'http://www.nexml.org/2009',        

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

Prefer symbols instead of strings as hash keys.
Open

'xmlns'              => 'http://www.nexml.org/2009',                  

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

unexpected token kEND (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

  end

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

Tagging a string as html safe may be a security risk.
Open

        object.alternate_values.collect { |a| content_tag(:li, alternate_value_annotation_tag(a)) }.join.html_safe

This cop checks for the use of output safety calls like html_safe, raw, and safe_concat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

Example:

user_content = "hi"

# bad
"

#{user_content}

".html_safe # => ActiveSupport::SafeBuffer "

hi

" # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

<b>hi</b>

" # bad out = "" out << "
  • #{user_content}
  • " out << "
  • #{user_content}
  • " out.html_safe # => ActiveSupport::SafeBuffer "
  • hi
  • hi
  • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
  • <b>hi</b>
  • <b>hi</b>
  • " # bad out = "

    trusted content

    ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

    trusted_content

    hi" # good out = "

    trusted content

    ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

    trusted_content

    <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

    Tagging a string as html safe may be a security risk.
    Open

                ( v.count > 0 ?  tag.div(v.join.html_safe, class: :annotations_summary_list, 'data-annotator-list-object-id' => object.id) : tag.em('None'))
    Severity: Minor
    Found in app/helpers/annotations_helper.rb by rubocop

    This cop checks for the use of output safety calls like html_safe, raw, and safe_concat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

    Example:

    user_content = "hi"
    
    # bad
    "

    #{user_content}

    ".html_safe # => ActiveSupport::SafeBuffer "

    hi

    " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

    <b>hi</b>

    " # bad out = "" out << "
  • #{user_content}
  • " out << "
  • #{user_content}
  • " out.html_safe # => ActiveSupport::SafeBuffer "
  • hi
  • hi
  • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
  • <b>hi</b>
  • <b>hi</b>
  • " # bad out = "

    trusted content

    ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

    trusted_content

    hi" # good out = "

    trusted content

    ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

    trusted_content

    <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

    Prefer self[:attr] = val over write_attribute(:attr, val).
    Open

            write_attribute(:hub_favorites, h)
    Severity: Minor
    Found in app/models/user/preferences.rb by rubocop

    This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

    If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

    Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

    Example:

    # bad
    x = read_attribute(:attr)
    write_attribute(:attr, val)
    
    # good
    x = self[:attr]
    self[:attr] = val

    Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
    Open

              json.cite_as "#{p.name} curators. #{Time.now.year}. Valid species for #{label_for_taxon_name(n)} in #{p.name}, a database in TaxonWorks. Accessed #{Time.now} by #{request.url}." 

    This cop checks for the use of Time methods without zone.

    Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

    Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

    When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

    Example: EnforcedStyle: strict

    # `strict` means that `Time` should be used with `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # bad
    Time.current
    Time.at(timestamp).in_time_zone
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')

    Example: EnforcedStyle: flexible (default)

    # `flexible` allows usage of `in_time_zone` instead of `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')
    
    # good
    Time.current
    Time.at(timestamp).in_time_zone

    unexpected token tRPAREN (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

        json.set!("Past week: New citations", Citation.where(created_at: 1.week.ago..).count)

    This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

    unexpected token tRPAREN (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

        json.set!("Past week: New images", Image.where(created_at: 1.week.ago..).count)

    This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

    unexpected token tCOMMA (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

        json.set!("Past week: New project sources", ProjectSource.where(created_at: 1.week.ago.., project_id: @project_id).count)

    This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

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

    json.partial! "/attributions/attributes", attribution: @attribution

    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

    json.partial! "otu_relationships/attributes", otu_relationship: @otu_relationship

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

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

    Example: EnforcedStyle: double_quotes

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

    Prefer the new style validations validates :column, uniqueness: value over validates_uniqueness_of.
    Open

      validates_uniqueness_of :type_type, scope: [:protonym_id, :collection_object_id]
    Severity: Minor
    Found in app/models/type_material.rb by rubocop

    This cop checks for the use of old-style attribute validation macros.

    Example:

    # bad
    validates_acceptance_of :foo
    validates_confirmation_of :foo
    validates_exclusion_of :foo
    validates_format_of :foo
    validates_inclusion_of :foo
    validates_length_of :foo
    validates_numericality_of :foo
    validates_presence_of :foo
    validates_absence_of :foo
    validates_size_of :foo
    validates_uniqueness_of :foo
    
    # good
    validates :foo, acceptance: true
    validates :foo, confirmation: true
    validates :foo, exclusion: true
    validates :foo, format: true
    validates :foo, inclusion: true
    validates :foo, length: true
    validates :foo, numericality: true
    validates :foo, presence: true
    validates :foo, absence: true
    validates :foo, size: true
    validates :foo, uniqueness: true

    unexpected token tRPAREN (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

        json.set!("Past week: New observations", Observation.where(created_at: 1.week.ago..).count)

    This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

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

    json.partial! "import_datasets/import_dataset", import_dataset: @import_dataset, filters: @filters

    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 symbols instead of strings as hash keys.
    Open

    'xmlns:foaf'         => 'http://xmlns.com/foaf/0.1/',

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    unexpected token tRPAREN (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

    json.partial!('/taxon_names/api/v1/base_attributes', taxon_name:)

    This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

    Severity
    Category
    Status
    Source
    Language