hacken-in/hacken-in

View on GitHub

Showing 143 of 144 total issues

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 SingleEvent::search (43.6)
    Open

      def self.search(search)
        search.strip!
        # Name + Description in Single Event
        sevents = today_or_in_future.name_or_description_like("%#{search}%")
    
    
    Severity: Minor
    Found in app/models/single_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

    Class User has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ActiveRecord::Base
      # Include default devise modules. Others available are:
      # :token_authenticatable, :confirmable, :lockable and :timeoutable
      devise :database_authenticatable, :registerable, :omniauthable,
             :recoverable, :rememberable, :trackable, :validatable
    Severity: Minor
    Found in app/models/user.rb - About 2 hrs to fix

      Complex method TwitterFollower#event_twitter_handles (39.0)
      Open

        def event_twitter_handles
          (
            Event.select(:twitter).uniq.map(&:twitter) +
            SingleEvent.select("single_events.twitter").uniq.map(&:twitter)
          ).compact.uniq.map(&:downcase).delete_if(&:blank?) - ["hacken_in"]
      Severity: Minor
      Found in lib/twitter_follower.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 main#update (38.6)
      Open

          def update
            params[:event][:schedule_rules] = JSON.parse(params[:event][:schedule_rules]) if params[:event][:schedule_rules]
            params[:event][:excluded_times] = JSON.parse(params[:event][:excluded_times]) if params[:event][:excluded_times]
            reconstruct_start_time
            update! do |success|
      Severity: Minor
      Found in app/admin/events.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#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

      Method update_with_password_pass has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_with_password_pass(params={})
      
          if params[:password].blank? and params[:email] == self.email
            params.delete(:current_password)
            params.delete(:password)
      Severity: Minor
      Found in app/models/user.rb - About 1 hr 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

      Complex method Radar::Ical#parse_event (34.7)
      Open

          def parse_event(event)
            result = {
              id: event.start.to_s,
              url: event.url.to_s,
              title: (event.summary || "").force_encoding("utf-8"),
      Severity: Minor
      Found in lib/radar/ical.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 SingleEvent#is_for_user? (31.6)
      Open

        def is_for_user?(user)
          return true unless user
          # Let us be a little more verbose than the old code
          # !((self.event.tag_list & user.hate_list).length > 0 && self.users.exclude?(user))
          hated_tags_event = (self.event.tag_list & user.hate_list)
      Severity: Minor
      Found in app/models/single_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

      Method <=> has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def <=>(other)
          if (self.occurrence.year != other.occurrence.year) || (self.occurrence.month != other.occurrence.month) || (self.occurrence.day != other.occurrence.day)
            # not on same day
            return self.occurrence <=> other.occurrence
          elsif self.full_day
      Severity: Minor
      Found in app/models/single_event.rb - About 1 hr 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

      Complex method User#update_with_password_pass (30.8)
      Open

        def update_with_password_pass(params={})
      
          if params[:password].blank? and params[:email] == self.email
            params.delete(:current_password)
            params.delete(:password)
      Severity: Minor
      Found in app/models/user.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

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

        def initialize(user)
          if user.present? && user.admin?
            can :manage, :all
          elsif user.present?
            # Achtung! Keine Blocks benutzen, sondern immer die
      Severity: Minor
      Found in app/models/active_admin_ability.rb - About 1 hr 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 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(user)
          if user.present? && user.admin?
            can :manage, :all
          elsif user.present?
            # Achtung! Keine Blocks benutzen, sondern immer die
      Severity: Minor
      Found in app/models/active_admin_ability.rb - About 1 hr to fix

        Complex method main#permitted_params (28.6)
        Open

            def permitted_params
              params.permit(venue: [
                :location,
                :street,
                :zipcode,
        Severity: Minor
        Found in app/admin/venue.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

            def update
              params[:event][:schedule_rules] = JSON.parse(params[:event][:schedule_rules]) if params[:event][:schedule_rules]
              params[:event][:excluded_times] = JSON.parse(params[:event][:excluded_times]) if params[:event][:excluded_times]
              reconstruct_start_time
              update! do |success|
        Severity: Major
        Found in app/admin/events.rb and 1 other location - About 1 hr to fix
        app/admin/events.rb on lines 71..77

        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 48.

        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

            def create
              params[:event][:schedule_rules] = JSON.parse(params[:event][:schedule_rules]) if params[:event][:schedule_rules]
              params[:event][:excluded_times] = JSON.parse(params[:event][:excluded_times]) if params[:event][:excluded_times]
              reconstruct_start_time
              create! do |success|
        Severity: Major
        Found in app/admin/events.rb and 1 other location - About 1 hr to fix
        app/admin/events.rb on lines 82..88

        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 48.

        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

        Complex method ParticipatesController#update (27.5)
        Open

          def update
            @single_event = SingleEvent.find params[:single_event_id]
        
            if push_or_delete(params[:state].to_s)
              flash[:notice] = t "single_events.#{params[:state]}.confirmation"

        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 ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#reset_pk_sequence! (27.0)
        Open

                        def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
                            unless pk and sequence
                                default_pk, default_sequence = pk_and_sequence_for(table)
        
                                pk ||= default_pk

        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 SingleEvent#to_opengraph (26.7)
        Open

          def to_opengraph
            ogdata = event.to_opengraph.merge({
              "og:title"       => name_with_date,
              "og:description" => short_description
            })
        Severity: Minor
        Found in app/models/single_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 LayoutHelper#display_error_messages! (26.4)
        Open

          def display_error_messages!
            return "" if resource.errors.empty?
        
            messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
            sentence = I18n.t("errors.messages.not_saved",
        Severity: Minor
        Found in app/helpers/layout_helper.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

        Severity
        Category
        Status
        Source
        Language