znamenica/dneslov

View on GitHub
app/models/slug.rb

Summary

Maintainability
A
0 mins
Test Coverage
B
82%

Assignment Branch Condition size for base= is too high. [42.61/30]
Open

   def base= value
      digits = value.mb_chars.downcase.to_s.gsub(/[^0-9]+/, '')
      words = value.gsub(/[0-9]+/, '').split(/\s+/).select do |x|
         x.mb_chars.downcase.to_s != x ;end
      .map do |x|
Severity: Minor
Found in app/models/slug.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. [20/15]
Open

   def base= value
      digits = value.mb_chars.downcase.to_s.gsub(/[^0-9]+/, '')
      words = value.gsub(/[0-9]+/, '').split(/\s+/).select do |x|
         x.mb_chars.downcase.to_s != x ;end
      .map do |x|
Severity: Minor
Found in app/models/slug.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.

Space inside parentheses detected.
Open

   scope :for_calendary, -> { where( sluggable_type: 'Calendary' ) }
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Do not use space inside reference brackets.
Open

         firsts[ 0...5 ].join
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Space inside parentheses detected.
Open

   scope :for_calendary, -> { where( sluggable_type: 'Calendary' ) }
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Do not use space inside reference brackets.
Open

         last = words[ 1 ].gsub( /[аеёиоуъыьэюя]+/, '' )[ 0...3 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Indent the first parameter one step more than the start of the previous line.
Open

      if digits.size > 3
         digits[0..5]
      elsif digits.size > 0
         digits + firsts[ 0...4 - digits.size ].join
      elsif firsts.size > 2
Severity: Minor
Found in app/models/slug.rb by rubocop

This cop checks the indentation of the first parameter in a method call. Parameters after the first one are checked by Style/AlignParameters, not by this cop.

Example:

# bad
some_method(
first_param,
second_param)

# good
some_method(
  first_param,
second_param)

Do not use space inside reference brackets.
Open

         last = words[ 1 ].gsub( /[аеёиоуъыьэюя]+/, '' )[ 0...3 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Do not use space inside reference brackets.
Open

         first = words[ 0 ][ 0...5 - last.size ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Do not use space inside reference brackets.
Open

         digits + firsts[ 0...4 - digits.size ].join
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Align .map with .gsub on line 17.
Open

      .map do |x|
Severity: Minor
Found in app/models/slug.rb by rubocop

This cop checks the indentation of the method name part in method calls that span more than one line.

Example: EnforcedStyle: aligned

# bad
while myvariable
.b
  # do something
end

# good
while myvariable
      .b
  # do something
end

# good
Thing.a
     .b
     .c

Example: EnforcedStyle: indented

# good
while myvariable
  .b

  # do something
end

Example: EnforcedStyle: indentedrelativeto_receiver

# good
while myvariable
        .a
        .b

  # do something
end

# good
myvariable = Thing
               .a
               .b
               .c

Do not use space inside reference brackets.
Open

         last = words[ 1 ].gsub( /[аеёиоуъыьэюя]+/, '' )[ 0...3 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Space found before semicolon.
Open

         x.mb_chars.downcase ;end
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for semicolon (;) preceded by space.

Example:

# bad
x = 1 ; y = 2

# good
x = 1; y = 2

Do not use space inside reference brackets.
Open

         firsts[ 0...5 ].join
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Space missing after semicolon.
Open

         x.mb_chars.downcase.to_s != x ;end
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for semicolon (;) not followed by some kind of space.

Example:

# bad
x = 1;y = 2

# good
x = 1; y = 2

Use only ascii symbols in comments.
Open

# related_to[belongs_to]      - отношение к предмету
Severity: Minor
Found in app/models/slug.rb by rubocop

This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).

Example:

# bad
# Translates from English to 日本語。

# good
# Translates from English to Japanese

Do not use space inside reference brackets.
Open

         first = words[ 0 ][ 0...5 - last.size ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Space inside parentheses detected.
Open

         last = words[ 1 ].gsub( /[аеёиоуъыьэюя]+/, '' )[ 0...3 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Do not use space inside reference brackets.
Open

         digits + firsts[ 0...4 - digits.size ].join
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Expression at 18, 41 should be on its own line.
Open

         x.mb_chars.downcase.to_s != x ;end
Severity: Minor
Found in app/models/slug.rb by rubocop

This cop checks whether the end statement of a do..end block is on its own line.

Example:

# bad
blah do |i|
  foo(i) end

# good
blah do |i|
  foo(i)
end

# bad
blah { |i|
  foo(i) }

# good
blah { |i|
  foo(i)
}

Space missing after semicolon.
Open

         x.mb_chars.downcase ;end
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for semicolon (;) not followed by some kind of space.

Example:

# bad
x = 1;y = 2

# good
x = 1; y = 2

Space found before semicolon.
Open

         x.mb_chars.downcase.to_s != x ;end
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for semicolon (;) preceded by space.

Example:

# bad
x = 1 ; y = 2

# good
x = 1; y = 2

Space inside parentheses detected.
Open

         last = words[ 1 ].gsub( /[аеёиоуъыьэюя]+/, '' )[ 0...3 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Use only ascii symbols in comments.
Open

# text[string]                - кратко по предмету
Severity: Minor
Found in app/models/slug.rb by rubocop

This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).

Example:

# bad
# Translates from English to 日本語。

# good
# Translates from English to Japanese

Do not use space inside reference brackets.
Open

         words.first[ 0..5 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Do not use space inside reference brackets.
Open

         first = words[ 0 ][ 0...5 - last.size ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Do not use space inside reference brackets.
Open

         last = words[ 1 ].gsub( /[аеёиоуъыьэюя]+/, '' )[ 0...3 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Do not use space inside reference brackets.
Open

         first = words[ 0 ][ 0...5 - last.size ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Do not use space inside reference brackets.
Open

         words.first[ 0..5 ]
Severity: Minor
Found in app/models/slug.rb by rubocop

Checks that reference brackets have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: no_space (default)

# The `no_space` style enforces that reference brackets have
# no surrounding space.

# bad
hash[ :key ]
array[ index ]

# good
hash[:key]
array[index]

Example: EnforcedStyle: space

# The `space` style enforces that reference brackets have
# surrounding space.

# bad
hash[:key]
array[index]

# good
hash[ :key ]
array[ index ]

Use !empty? instead of size > 0.
Open

      elsif digits.size > 0
Severity: Minor
Found in app/models/slug.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?

Expression at 20, 31 should be on its own line.
Open

         x.mb_chars.downcase ;end
Severity: Minor
Found in app/models/slug.rb by rubocop

This cop checks whether the end statement of a do..end block is on its own line.

Example:

# bad
blah do |i|
  foo(i) end

# good
blah do |i|
  foo(i)
end

# bad
blah { |i|
  foo(i) }

# good
blah { |i|
  foo(i)
}

Indent the first line of the right-hand-side of a multi-line assignment.
Open

      if digits.size > 3
         digits[0..5]
      elsif digits.size > 0
         digits + firsts[ 0...4 - digits.size ].join
      elsif firsts.size > 2
Severity: Minor
Found in app/models/slug.rb by rubocop

This cop checks the indentation of the first line of the right-hand-side of a multi-line assignment.

Example:

# bad
value =
if foo
  'bar'
end

# good
value =
  if foo
    'bar'
  end

The indentation of the remaining lines can be corrected with other cops such as IndentationConsistency and EndAlignment.

Avoid multi-line chains of blocks.
Open

         x.mb_chars.downcase.to_s != x ;end
      .map do |x|
Severity: Minor
Found in app/models/slug.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

There are no issues that match your filters.

Category
Status