hacken-in/hacken-in

View on GitHub
app/models/event.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class Event has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class Event < ActiveRecord::Base
  include TwitterHashTagFixer

  validates_presence_of :name
  validates_presence_of :category
Severity: Minor
Found in app/models/event.rb - About 2 hrs to fix

    Complex method Event#schedule_rules (37.5)
    Open

      def schedule_rules
        schedule.recurrence_rules.map do |rule|
          hash = {}
          if rule.class == IceCube::MonthlyRule
            hash["type"] = 'monthly'
    Severity: Minor
    Found in app/models/event.rb by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method Event#future_single_event_creation (22.2)
    Open

      def future_single_event_creation
        self.schedule.next_occurrences(12).each do |occurrence|
          if !self.schedule.extimes.map(&:to_i).include? occurrence.to_i
            SingleEvent.where(event_id: self.id,
                              occurrence: occurrence.utc,
    Severity: Minor
    Found in app/models/event.rb by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method Event#closest_single_event (20.4)
    Open

      def closest_single_event(date=Date.today)
        return nil if single_events.to_a.empty?
    
        coming_up = single_events.to_a.select { |s| s.occurrence.to_date >= date }.sort_by { |s| s.occurrence }
    
    
    Severity: Minor
    Found in app/models/event.rb by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

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

            hash["type"] = 'weekly'
            hash["interval"] = rule.validations_for(:interval).first.interval
            hash["days"] = rule.validations_for(:day).map{|d| Date::DAYNAMES[d.day].downcase}
    Severity: Minor
    Found in app/models/event.rb and 1 other location - About 20 mins to fix
    app/models/event.rb on lines 121..123

    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 2 locations. Consider refactoring.
    Open

            hash["type"] = 'monthly'
            hash["interval"] = rule.validations_for(:day_of_week).first.occ
            hash["days"] = rule.validations_for(:day_of_week).map{|d| Date::DAYNAMES[d.day].downcase}
    Severity: Minor
    Found in app/models/event.rb and 1 other location - About 20 mins to fix
    app/models/event.rb on lines 125..127

    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

    There are no issues that match your filters.

    Category
    Status