prellele/trame

View on GitHub

Showing 15 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      scope :by_daterange, lambda { |range| where("start_time >= ? and start_time <= ?", 
          DateTime.strptime(range.split(' - ')[0],I18n.t("date.formats.date_format")),
          DateTime.strptime("#{range.split(' - ')[1]} 23:59",I18n.t("time.formats.datetime"))) }
    Severity: Minor
    Found in app/models/tracking.rb and 1 other location - About 25 mins to fix
    app/models/attendance.rb on lines 9..11

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      scope :by_daterange, lambda { |range| where("start >= ? and start <= ?", 
          DateTime.strptime(range.split(' - ')[0],I18n.t("date.formats.date_format")),
          DateTime.strptime("#{range.split(' - ')[1]} 23:59",I18n.t("time.formats.datetime"))) }
    Severity: Minor
    Found in app/models/attendance.rb and 1 other location - About 25 mins to fix
    app/models/tracking.rb on lines 14..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      def update
        @invoice = Invoice.find(params[:id])
        if @invoice.update_attributes(params[:invoice])
          redirect_to @invoice, notice: t("flash.notice.successfully_updated", class: t("invoices.invoice") )
        else
    Severity: Minor
    Found in app/controllers/invoices_controller.rb and 4 other locations - About 20 mins to fix
    app/controllers/clients_controller.rb on lines 33..39
    app/controllers/projects_controller.rb on lines 38..44
    app/controllers/roles_controller.rb on lines 36..42
    app/controllers/tickets_controller.rb on lines 40..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 28.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      def update
        @role = Role.find(params[:id])
        if @role.update_attributes(params[:role])
          redirect_to @role, notice: t("flash.notice.successfully_updated", class: t("roles.role") )
        else
    Severity: Minor
    Found in app/controllers/roles_controller.rb and 4 other locations - About 20 mins to fix
    app/controllers/clients_controller.rb on lines 33..39
    app/controllers/invoices_controller.rb on lines 39..45
    app/controllers/projects_controller.rb on lines 38..44
    app/controllers/tickets_controller.rb on lines 40..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 28.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      def update
        @ticket = Ticket.find(params[:id])
        if @ticket.update_attributes(params[:ticket])
          redirect_to @ticket, notice: t("flash.notice.successfully_updated", class: t("tickets.ticket") )
        else
    Severity: Minor
    Found in app/controllers/tickets_controller.rb and 4 other locations - About 20 mins to fix
    app/controllers/clients_controller.rb on lines 33..39
    app/controllers/invoices_controller.rb on lines 39..45
    app/controllers/projects_controller.rb on lines 38..44
    app/controllers/roles_controller.rb on lines 36..42

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 28.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      def update
        @client = Client.find(params[:id])
        if @client.update_attributes(params[:client])
          redirect_to @client, notice: t("flash.notice.successfully_updated", class: t("clients.client") )
        else
    Severity: Minor
    Found in app/controllers/clients_controller.rb and 4 other locations - About 20 mins to fix
    app/controllers/invoices_controller.rb on lines 39..45
    app/controllers/projects_controller.rb on lines 38..44
    app/controllers/roles_controller.rb on lines 36..42
    app/controllers/tickets_controller.rb on lines 40..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 28.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      def update
        @project = Project.find(params[:id])
        if @project.update_attributes(params[:project])
          redirect_to @project, notice: t("flash.notice.successfully_updated", class: t("projects.project") )
        else
    Severity: Minor
    Found in app/controllers/projects_controller.rb and 4 other locations - About 20 mins to fix
    app/controllers/clients_controller.rb on lines 33..39
    app/controllers/invoices_controller.rb on lines 39..45
    app/controllers/roles_controller.rb on lines 36..42
    app/controllers/tickets_controller.rb on lines 40..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 28.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

      def create
        @client = Client.new(params[:client])
        if @client.save
          redirect_to @client, notice: t("flash.notice.successfully_created", class: t("clients.client") )
        else
    Severity: Minor
    Found in app/controllers/clients_controller.rb and 3 other locations - About 15 mins to fix
    app/controllers/projects_controller.rb on lines 28..34
    app/controllers/roles_controller.rb on lines 26..32
    app/controllers/tickets_controller.rb on lines 30..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

      def create
        @ticket = Ticket.new(params[:ticket])
        if @ticket.save
          redirect_to @ticket, notice: t("flash.notice.successfully_created", class: t("tickets.ticket") )
        else
    Severity: Minor
    Found in app/controllers/tickets_controller.rb and 3 other locations - About 15 mins to fix
    app/controllers/clients_controller.rb on lines 23..29
    app/controllers/projects_controller.rb on lines 28..34
    app/controllers/roles_controller.rb on lines 26..32

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

      def create
        @project = Project.new(params[:project])
        if @project.save
          redirect_to @project, notice: t("flash.notice.successfully_created", class: t("projects.project") )
        else
    Severity: Minor
    Found in app/controllers/projects_controller.rb and 3 other locations - About 15 mins to fix
    app/controllers/clients_controller.rb on lines 23..29
    app/controllers/roles_controller.rb on lines 26..32
    app/controllers/tickets_controller.rb on lines 30..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

      def create
        @role = Role.new(params[:role])
        if @role.save
          redirect_to @role, notice: t("flash.notice.successfully_created", class: t("roles.role") )
        else
    Severity: Minor
    Found in app/controllers/roles_controller.rb and 3 other locations - About 15 mins to fix
    app/controllers/clients_controller.rb on lines 23..29
    app/controllers/projects_controller.rb on lines 28..34
    app/controllers/tickets_controller.rb on lines 30..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Severity
    Category
    Status
    Source
    Language