Assignment Branch Condition size for range_to_ampm is too high. [23.17/15] Open
def range_to_ampm(range)
start_hour = range[0..1].to_i
end_hour = range[6..7].to_i
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
end
- Read upRead up
- Exclude checks
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
Surrounding space missing for operator +
. Open
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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. [176/80] Open
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Exclude checks
Use 2 (not 4) spaces for indentation. Open
start_hour = range[0..1].to_i
- Read upRead up
- Exclude checks
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
Surrounding space missing for operator -
. Open
(((start_hour-1)%12)+1).to_s + range[2..4] + ((start_hour%24)<12?' a.m. - ':' p.m. - ') + (((end_hour-1)%12)+1).to_s + range[8..10] + ((end_hour%24)<12?' a.m.':' p.m.')
- Read upRead up
- Exclude checks
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 2 (not 4) spaces for indentation. Open
def range_to_ampm(range)
- Read upRead up
- Exclude checks
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