shapeable/prototype-web

View on GitHub
web-app/app/workers/api_weather_hazards.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Assignment Branch Condition size for send_message is too high. [24.35/15]
Open

  def send_message(value)
    UserAlarm.all.each do |user_alarm|
        if (user_alarm.alarm_id.to_s == Alarm.find_by(name: value).id.to_s) && Message.find_by_user_id_and_alarm_id(user_alarm.user_id, user_alarm.alarm_id).nil?
            user = User.find(user_alarm.user_id)
            if user.email_actived

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. [19/10]
Open

  def parse_json_value(json_value, value, type)
    if !json_value['features'].nil? && json_value['features'].count > 0
        json_value['features'].each do |feature|
            if type == "weather"
                end_date = feature['attributes']['end_date']

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 parse_json_value is too high. [23.43/15]
Open

  def parse_json_value(json_value, value, type)
    if !json_value['features'].nil? && json_value['features'].count > 0
        json_value['features'].each do |feature|
            if type == "weather"
                end_date = feature['attributes']['end_date']

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. [14/10]
Open

  def get_json_from_type(name, type)
    if type == "weather"
        json = "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Climate_Outlooks/cpc_weather_hazards/MapServer/1/query?"+
        "where=&text=#{name.to_param}+&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+
        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=start_date%2C+end_date&returnGeometry=true"+

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. [12/10]
Open

  def send_message(value)
    UserAlarm.all.each do |user_alarm|
        if (user_alarm.alarm_id.to_s == Alarm.find_by(name: value).id.to_s) && Message.find_by_user_id_and_alarm_id(user_alarm.user_id, user_alarm.alarm_id).nil?
            user = User.find(user_alarm.user_id)
            if user.email_actived

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 parse_json_value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_json_value(json_value, value, type)
    if !json_value['features'].nil? && json_value['features'].count > 0
        json_value['features'].each do |feature|
            if type == "weather"
                end_date = feature['attributes']['end_date']
Severity: Minor
Found in web-app/app/workers/api_weather_hazards.rb - About 1 hr 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 send_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def send_message(value)
    UserAlarm.all.each do |user_alarm|
        if (user_alarm.alarm_id.to_s == Alarm.find_by(name: value).id.to_s) && Message.find_by_user_id_and_alarm_id(user_alarm.user_id, user_alarm.alarm_id).nil?
            user = User.find(user_alarm.user_id)
            if user.email_actived
Severity: Minor
Found in web-app/app/workers/api_weather_hazards.rb - About 55 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 2 (not 4) spaces for indentation.
Open

                end_date = feature['attributes']['end_date']

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

Use 2 (not 4) spaces for indentation.
Open

                ring.each do |coordenate|

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

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

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=start_date%2C+end_date&returnGeometry=true"+

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Use 2 (not 4) spaces for indentation.
Open

        json = "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Climate_Outlooks/cpc_weather_hazards/MapServer/1/query?"+

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

Use 2 (not 4) spaces for indentation.
Open

                        send_message(value)

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

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

        "&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Use 2 (not 4) spaces for indentation.
Open

            user = User.find(user_alarm.user_id)

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

Use 2 (not 4) spaces for indentation.
Open

        json = get_json_from_url(url_main)

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

Use 2 (not 4) spaces for indentation.
Open

                    if  GeographicManager.point_in_polygon(coordenate[0], coordenate[1])

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

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

        "&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson&__ncforminfo=uCzgGetb_239kWlDp1W4D44sFk2Ba6HD9oRQDJQEIVDya_62Q9VVuSjXV1vraAswK2eAdHMhgX1gAYsHzsuGCY4XW8_BuQuFLuO8GtOYQEoSZj-Es5XEJ5qDBTEU2XWpeSZAiSljcJULyWLbNQ_HzKrgNQORKMR_XfUT0rllN2jNctJZGbWVCv5RZUC4_Hh62_E71PQMDGu0zaCDKbpanO4Kam4YXOd1lfUj09z5wZosmApYsFHhB0_DagBj4rlgpJ9XrxRSE0VuHfRv8C2gc7a29MHhBuhXq3es1lAo_VvCR8OzPBxMFJhsBKFab1osA3BoCRaIpeO4-ZwJIYXVBWUeV6two-tOeNsISaeY3yyXZ_jwRn80sITcR0mR968KMh8rBeDUDH_NjRk2pmqxCyfPrc6Zkv96SXgawT5NA5x6TfGHUqc0qkfutoZK5uiRxhXHjmJT7uDhuBWx7HK560z-PnyizJalaHvrvdKEvQCJJKtK5YMboEWPeRkpNHMQX0CbenIERyP-Ancw9subm_MHSlNe_8ZIvM40aJYpI4_bVeTDYRtoSQ%3D%3D"

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

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

        "&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics="+

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Inconsistent indentation detected.
Open

      JSON.load(open(json))

This cops checks for inconsistent indentation.

Example:

class A
  def test
    puts 'hello'
     puts 'world'
  end
end

Use 2 (not 4) spaces for indentation.
Open

                NotificationCenter.send_mail_message(user.email, "An alert concerning #{value} has been detected. Please wait for updated information", 'California Alert')

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

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

        "where=&text=#{name.to_param}+&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Use empty lines between method definitions.
Open

  def send_message(value)

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Use 2 (not 4) spaces for indentation.
Open

        puts "#{value} has not values"

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

Use 2 (not 4) spaces for indentation.
Open

                NotificationCenter.send_sms_message(user.phone_number, "An alert concerning #{value} has been detected. Please wait for updated information")

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

Use 2 (not 4) spaces for indentation.
Open

      JSON.load(open(url_main))

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

Use 2 (not 4) spaces for indentation.
Open

            if type == "weather"

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

Use 2 (not 4) spaces for indentation.
Open

        puts ex.message

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

Use 2 (not 4) spaces for indentation.
Open

        json_value['features'].each do |feature|

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

Use 2 (not 4) spaces for indentation.
Open

        json = "https://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/12/query?"+

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

Keep a blank line before and after private.
Open

  private

Access modifiers should be surrounded by blank lines.

Example:

# bad
class Foo
  def bar; end
  private
  def baz; end
end

# good
class Foo
  def bar; end

  private

  def baz; end
end

Missing space after #.
Open

#ApiWeatherHazards.perform_async

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

Example:

# bad
#Some comment

# good
# Some comment

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

        "&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields="+

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Use 2 (not 4) spaces for indentation.
Open

        if (user_alarm.alarm_id.to_s == Alarm.find_by(name: value).id.to_s) && Message.find_by_user_id_and_alarm_id(user_alarm.user_id, user_alarm.alarm_id).nil?

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

Use \ instead of + or << to concatenate those strings.
Open

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset="+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

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

            if type == "weather"

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 JSON.parse over JSON.load.
Open

      JSON.load(open(url_main))

This cop checks for the use of JSON class methods which have potential security issues.

Autocorrect is disabled by default because it's potentially dangerous. If using a stream, like JSON.load(open('file')), it will need to call #read manually, like JSON.parse(open('file').read). If reading single values (rather than proper JSON objects), like JSON.load('false'), it will need to pass the quirks_mode: true option, like JSON.parse('false', quirks_mode: true). Other similar issues may apply.

Example:

# always offense
JSON.load("{}")
JSON.restore("{}")

# no offense
JSON.parse("{}")

Line is too long. [90/80]
Open

        json = "https://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/12/query?"+

Line is too long. [686/80]
Open

        "&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson&__ncforminfo=uCzgGetb_239kWlDp1W4D44sFk2Ba6HD9oRQDJQEIVDya_62Q9VVuSjXV1vraAswK2eAdHMhgX1gAYsHzsuGCY4XW8_BuQuFLuO8GtOYQEoSZj-Es5XEJ5qDBTEU2XWpeSZAiSljcJULyWLbNQ_HzKrgNQORKMR_XfUT0rllN2jNctJZGbWVCv5RZUC4_Hh62_E71PQMDGu0zaCDKbpanO4Kam4YXOd1lfUj09z5wZosmApYsFHhB0_DagBj4rlgpJ9XrxRSE0VuHfRv8C2gc7a29MHhBuhXq3es1lAo_VvCR8OzPBxMFJhsBKFab1osA3BoCRaIpeO4-ZwJIYXVBWUeV6two-tOeNsISaeY3yyXZ_jwRn80sITcR0mR968KMh8rBeDUDH_NjRk2pmqxCyfPrc6Zkv96SXgawT5NA5x6TfGHUqc0qkfutoZK5uiRxhXHjmJT7uDhuBWx7HK560z-PnyizJalaHvrvdKEvQCJJKtK5YMboEWPeRkpNHMQX0CbenIERyP-Ancw9subm_MHSlNe_8ZIvM40aJYpI4_bVeTDYRtoSQ%3D%3D"

Use \ instead of + or << to concatenate those strings.
Open

        "&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics="+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

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

    elsif type == "general"

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

Line is too long. [107/80]
Open

        "where=&text=#{name.to_param}+&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

Use \ instead of + or << to concatenate those strings.
Open

        "&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields="+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

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

        "&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics="+

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 JSON.parse over JSON.load.
Open

      JSON.load(open(json))

This cop checks for the use of JSON class methods which have potential security issues.

Autocorrect is disabled by default because it's potentially dangerous. If using a stream, like JSON.load(open('file')), it will need to call #read manually, like JSON.parse(open('file').read). If reading single values (rather than proper JSON objects), like JSON.load('false'), it will need to pass the quirks_mode: true option, like JSON.parse('false', quirks_mode: true). Other similar issues may apply.

Example:

# always offense
JSON.load("{}")
JSON.restore("{}")

# no offense
JSON.parse("{}")

Surrounding space missing for operator +.
Open

        "where=&text=#{name.to_param}&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

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

Line is too long. [106/80]
Open

        "where=&text=#{name.to_param}&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
Open

    rescue Exception => ex
        puts ex.message

This cop checks for rescue blocks targeting the Exception class.

Example:

# bad

begin
  do_something
rescue Exception
  handle_exception
end

Example:

# good

begin
  do_something
rescue ArgumentError
  handle_exception
end

Useless assignment to variable - json.
Open

        json = get_json_from_url(url_main)

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - start_date.
Open

                start_date = feature['attributes']['start_date']

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Line is too long. [122/80]
Open

        "&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics="+

Use \ instead of + or << to concatenate those strings.
Open

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=start_date%2C+end_date&returnGeometry=true"+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

Redundant begin block detected.
Open

    begin

This cop checks for redundant begin blocks.

Currently it checks for code like this:

Example:

def redundant
  begin
    ala
    bala
  rescue StandardError => e
    something
  end
end

def preferred
  ala
  bala
rescue StandardError => e
  something
end

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

        "&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson&__ncforminfo=uCzgGetb_239kWlDp1W4D44sFk2Ba6HD9oRQDJQEIVDya_62Q9VVuSjXV1vraAswK2eAdHMhgX1gAYsHzsuGCY4XW8_BuQuFLuO8GtOYQEoSZj-Es5XEJ5qDBTEU2XWpeSZAiSljcJULyWLbNQ_HzKrgNQORKMR_XfUT0rllN2jNctJZGbWVCv5RZUC4_Hh62_E71PQMDGu0zaCDKbpanO4Kam4YXOd1lfUj09z5wZosmApYsFHhB0_DagBj4rlgpJ9XrxRSE0VuHfRv8C2gc7a29MHhBuhXq3es1lAo_VvCR8OzPBxMFJhsBKFab1osA3BoCRaIpeO4-ZwJIYXVBWUeV6two-tOeNsISaeY3yyXZ_jwRn80sITcR0mR968KMh8rBeDUDH_NjRk2pmqxCyfPrc6Zkv96SXgawT5NA5x6TfGHUqc0qkfutoZK5uiRxhXHjmJT7uDhuBWx7HK560z-PnyizJalaHvrvdKEvQCJJKtK5YMboEWPeRkpNHMQX0CbenIERyP-Ancw9subm_MHSlNe_8ZIvM40aJYpI4_bVeTDYRtoSQ%3D%3D"

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

        "&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields="+

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

Line is too long. [128/80]
Open

        "&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"

Line is too long. [171/80]
Open

                NotificationCenter.send_mail_message(user.email, "An alert concerning #{value} has been detected. Please wait for updated information", 'California Alert')

Use next to skip iteration.
Open

        if (user_alarm.alarm_id.to_s == Alarm.find_by(name: value).id.to_s) && Message.find_by_user_id_and_alarm_id(user_alarm.user_id, user_alarm.alarm_id).nil?

Use next to skip iteration instead of a condition at the end.

Example: EnforcedStyle: skipmodifierifs (default)

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

# good
[1, 2].each do |o|
  puts o unless o == 1
end

Example: EnforcedStyle: always

# With `always` all conditions at the end of an iteration needs to be
# replaced by next - with `skip_modifier_ifs` the modifier if like
# this one are ignored: `[1, 2].each { |a| return 'yes' if a == 1 }`

# bad
[1, 2].each do |o|
  puts o unless o == 1
end

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

Surrounding space missing for operator +.
Open

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=start_date%2C+end_date&returnGeometry=true"+

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

Surrounding space missing for operator +.
Open

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset="+

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

Use \ instead of + or << to concatenate those strings.
Open

        json = "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Climate_Outlooks/cpc_weather_hazards/MapServer/1/query?"+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

Use \ instead of + or << to concatenate those strings.
Open

        "where=&text=#{name.to_param}&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

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

        "&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

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

        "where=&text=#{name.to_param}&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Surrounding space missing for operator +.
Open

        "&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields="+

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

Surrounding space missing for operator +.
Open

        "where=&text=#{name.to_param}+&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

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

Surrounding space missing for operator +.
Open

        json = "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Climate_Outlooks/cpc_weather_hazards/MapServer/1/query?"+

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

Useless assignment to variable - end_date.
Open

                end_date = feature['attributes']['end_date']

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Line is too long. [114/80]
Open

        "&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields="+

Line is too long. [157/80]
Open

                NotificationCenter.send_sms_message(user.phone_number, "An alert concerning #{value} has been detected. Please wait for updated information")

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

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset="+

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

    end    

Line is too long. [88/80]
Open

                    if  GeographicManager.point_in_polygon(coordenate[0], coordenate[1])

Surrounding space missing for operator +.
Open

        json = "https://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/12/query?"+

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

end at 71, 4 is not aligned with def at 58, 2.
Open

    end

This cop checks whether the end keywords of method definitions are aligned properly.

Two modes are supported through the EnforcedStyleAlignWith configuration parameter. If it's set to start_of_line (which is the default), the end shall be aligned with the start of the line where the def keyword is. If it's set to def, the end shall be aligned with the def keyword.

Example: EnforcedStyleAlignWith: startofline (default)

# bad

private def foo
            end

# good

private def foo
end

Example: EnforcedStyleAlignWith: def

# bad

private def foo
            end

# good

private def foo
        end

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

    if type == "weather"

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

        "&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics="+

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

Line is too long. [161/80]
Open

        if (user_alarm.alarm_id.to_s == Alarm.find_by(name: value).id.to_s) && Message.find_by_user_id_and_alarm_id(user_alarm.user_id, user_alarm.alarm_id).nil?

Use \ instead of + or << to concatenate those strings.
Open

        json = "https://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/12/query?"+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

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

        json = "https://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/12/query?"+

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

Line is too long. [127/80]
Open

        json = "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Climate_Outlooks/cpc_weather_hazards/MapServer/1/query?"+

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

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset="+

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

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Line is too long. [115/80]
Open

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=start_date%2C+end_date&returnGeometry=true"+

Line is too long. [113/80]
Open

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset="+

Line is too long. [107/80]
Open

            Message.create(user_id: user_alarm.user_id, alarm_id: user_alarm.alarm_id, date_send: Time.now)

Use \ instead of + or << to concatenate those strings.
Open

        "where=&text=#{name.to_param}+&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR="+

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

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

        json = "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Climate_Outlooks/cpc_weather_hazards/MapServer/1/query?"+

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

        "&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=start_date%2C+end_date&returnGeometry=true"+

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"

There are no issues that match your filters.

Category
Status