znamenica/dneslov

View on GitHub
app/models/scriptum/canto.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method targets= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

   def targets= value
      if value.kind_of?( Array )
         new_value = value.map do |v|
            if v.kind_of?(String) && v =~ /^\^(.*)/
               Memory.where(short_name: $1).first
Severity: Minor
Found in app/models/scriptum/canto.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

%w-literals should be delimited by [ and ].
Open

   TYPES = %w(Canto Chant Canticle Orison Magnification Prayer Irmos IkosTroparion
              Stichira Kontakion Exapostilarion SessionalHymn Kanonion Kathismion
              Polileosion Apostichus CryStichira Stichiron)
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

%i-literals should be delimited by [ and ].
Open

   has_alphabeth on: %i(prosomeion_title)
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Avoid the use of Perl-style backrefs.
Open

               Memory.where(short_name: $1).first
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Space missing after semicolon.
Open

               v ;end;end
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

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

Example:

# bad
x = 1;y = 2

# good
x = 1; y = 2

Expression at 17, 23 should be on its own line.
Open

               v ;end;end
Severity: Minor
Found in app/models/scriptum/canto.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)
}

Align .compact with .map on line 13.
Open

            .compact
Severity: Minor
Found in app/models/scriptum/canto.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

Space inside parentheses detected.
Open

      if value.kind_of?( Array )
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

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

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

end at 17, 18 is not aligned with if at 14, 12.
Open

               v ;end;end
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)

Space found before semicolon.
Open

               v ;end;end
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

Checks for semicolon (;) preceded by space.

Example:

# bad
x = 1 ; y = 2

# good
x = 1; y = 2

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

      if value.kind_of?( Array )
Severity: Minor
Found in app/models/scriptum/canto.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)

Space missing after semicolon.
Open

               v ;end;end
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

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

Example:

# bad
x = 1;y = 2

# good
x = 1; y = 2

Missing top-level class documentation comment.
Open

class Canto < Scriptum
Severity: Minor
Found in app/models/scriptum/canto.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

Space inside parentheses detected.
Open

      if value.kind_of?( Array )
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

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

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

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

            if v.kind_of?(String) && v =~ /^\^(.*)/
Severity: Minor
Found in app/models/scriptum/canto.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)

Freeze mutable objects assigned to constants.
Open

   TYPES = %w(Canto Chant Canticle Orison Magnification Prayer Irmos IkosTroparion
              Stichira Kontakion Exapostilarion SessionalHymn Kanonion Kathismion
              Polileosion Apostichus CryStichira Stichiron)
Severity: Minor
Found in app/models/scriptum/canto.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

There are no issues that match your filters.

Category
Status