prellele/trame

View on GitHub

Showing 4 of 15 total issues

Method initialize has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(user)

    allow "devise/sessions", [:new, :create, :destroy]
    allow "devise/passwords", [:new, :create, :edit, :update]
    allow "devise/registrations", [:new, :create]
Severity: Minor
Found in app/models/permission.rb - About 4 hrs 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 initialize has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(user)

    allow "devise/sessions", [:new, :create, :destroy]
    allow "devise/passwords", [:new, :create, :edit, :update]
    allow "devise/registrations", [:new, :create]
Severity: Major
Found in app/models/permission.rb - About 2 hrs to fix

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

      def duration_in_words(minutes)
        min = minutes % 60
        hrs = minutes / 60
    
        duration_hrs = "#{t('time.formats.time_hrs', hours: hrs)}" if hrs > 0
    Severity: Minor
    Found in app/helpers/application_helper.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

    Method toggle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def toggle
        if @attendance = Attendance.where("start >= ?",Date.today).first
          @attendance.duration = ((Time.now - @attendance.start) / 60).to_i if @attendance.duration == 0
        else
          @attendance = current_user.attendances.new()
    Severity: Minor
    Found in app/controllers/attendances_controller.rb - About 25 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

    Severity
    Category
    Status
    Source
    Language