CommunityGrows/communitygrows

View on GitHub

Showing 21 of 187 total issues

Method send_doccom_update_email has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def send_doccom_update_email(committee, title)
        User.all.each do |user|
            if current_user.admin?
                NotificationMailer.document_update_email(user, Document.find_by_title(title)).deliver
            elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
Severity: Minor
Found in app/helpers/email_helper.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 send_announcement_email has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def send_announcement_email(committee, title)
        User.all.each do |user|
            if current_user.admin?
                NotificationMailer.announcement_email(user, Announcement.find_by_title(title)).deliver
            elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
Severity: Minor
Found in app/helpers/email_helper.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 send_announcement_update_email has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def send_announcement_update_email(committee, title)
        User.all.each do |user|
            if current_user.admin?
                NotificationMailer.announcement_update_email(user, Announcement.find_by_title(title)).deliver
            elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
Severity: Minor
Found in app/helpers/email_helper.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 send_doccom_email has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def send_doccom_email(committee, title)
        User.all.each do |user|
            if current_user.admin?
                NotificationMailer.document_update_email(user, Document.find_by_title(title)).deliver
            elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
Severity: Minor
Found in app/helpers/email_helper.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 create has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def create
        @title = event_params[:title]
        @location = event_params[:location]
        @description = event_params[:description]
        @date = event_params[:date]
Severity: Minor
Found in app/controllers/events_controller.rb - About 1 hr to fix

    Method create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def create
            @title = event_params[:title]
            @location = event_params[:location]
            @description = event_params[:description]
            @date = event_params[:date]
    Severity: Minor
    Found in app/controllers/events_controller.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 update has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def update
            @event = Event.find params[:id]
            @title = event_params[:title]
            @date = event_params[:date]
            if @title.empty?
    Severity: Minor
    Found in app/controllers/events_controller.rb - About 1 hr to fix

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

          def update
              @event = Event.find params[:id]
              @title = event_params[:title]
              @date = event_params[:date]
              if @title.empty?
      Severity: Minor
      Found in app/controllers/events_controller.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 update_category has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update_category
              if !current_user.admin
                  flash[:message] = "Only admins can create categories."
                  redirect_to root_path and return
              end
      Severity: Minor
      Found in app/controllers/category_controller.rb - About 1 hr to fix

        Method update_category has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_category
                if !current_user.admin
                    flash[:message] = "Only admins can create categories."
                    redirect_to root_path and return
                end
        Severity: Minor
        Found in app/controllers/category_controller.rb - About 55 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 create_category has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_category
                if !current_user.admin
                    flash[:message] = "Only admins can create categories."
                    redirect_to root_path and return
                end
        Severity: Minor
        Found in app/controllers/category_controller.rb - About 55 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 update_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_file
                @target_file = Document.find params[:format]
                @file = params[:file]
                if @file[:title].to_s == "" or @file[:url].to_s == ""
                    flash[:notice] = "Populate all fields before submission."
        Severity: Minor
        Found in app/controllers/documents_controller.rb - About 45 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 create_document has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_document
                if params[:title].to_s == "" or params[:url].to_s == ""
                    flash[:notice] = "Populate all fields before submission."
                    redirect_to new_committee_document_path
                elsif !(params[:url]=~/.com(.*)/)
        Severity: Minor
        Found in app/controllers/document_committee_controller.rb - About 45 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 create_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_file
                @file = params[:file]
                if @file[:title].to_s == "" or @file[:url].to_s == ""
                    flash[:notice] = "Populate all fields before submission."
                    redirect_to new_file_path
        Severity: Minor
        Found in app/controllers/documents_controller.rb - About 45 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 update_document has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_document
                if params[:title].to_s == "" or params[:url].to_s == ""
                    flash[:notice] = "Populate all fields before submission."
                    redirect_to new_committee_document_path
                elsif !(params[:url]=~/.com(.*)/)
        Severity: Minor
        Found in app/controllers/document_committee_controller.rb - About 45 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

        Consider simplifying this complex logical expression.
        Open

                    elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
                        if user.digest_pref == "daily"
                            NotificationMailer.announcement_update_email(user, Announcement.find_by_title(title)).deliver_later!(wait_until: (Time.now.tomorrow.noon - Time.now).seconds.from_now)
                        elsif user.digest_pref == "weekly"
                            NotificationMailer.announcement_update_email(user, Announcement.find_by_title(title)).deliver_later!(wait_until: (Time.now.next_week.noon - Time.now).seconds.from_now)
        Severity: Major
        Found in app/helpers/email_helper.rb - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                      elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
                          if user.digest_pref == "daily"
                              NotificationMailer.new_document_email(user, Document.find_by_title(title)).deliver_later!(wait_until: (Time.now.tomorrow.noon - Time.now).seconds.from_now)
                          elsif user.digest_pref == "weekly"
                              NotificationMailer.new_document_email(user, Document.find_by_title(title)).deliver_later!(wait_until: (Time.now.next_week.noon - Time.now).seconds.from_now)
          Severity: Major
          Found in app/helpers/email_helper.rb - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                        elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
                            if user.digest_pref == "daily"
                                NotificationMailer.document_update_email(user, Document.find_by_title(title)).deliver_later!(wait_until: (Time.now.tomorrow.noon - Time.now).seconds.from_now)
                            elsif user.digest_pref == "weekly"
                                NotificationMailer.document_update_email(user, Document.find_by_title(title)).deliver_later!(wait_until: (Time.now.next_week.noon - Time.now).seconds.from_now)
            Severity: Major
            Found in app/helpers/email_helper.rb - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                          elsif (committee == "internal" and user.internal?) or (committee == "external" and user.external?) or (committee == "executive" and user.executive?)
                              if user.digest_pref == "daily"
                                  NotificationMailer.announcement_email(user, Announcement.find_by_title(title)).deliver_later!(wait_until: (Time.now.tomorrow.noon - Time.now).seconds.from_now)
                              elsif user.digest_pref == "weekly"
                                  NotificationMailer.announcement_email(user, Announcement.find_by_title(title)).deliver_later!(wait_until: (Time.now.next_week.noon - Time.now).seconds.from_now)
              Severity: Major
              Found in app/helpers/email_helper.rb - About 40 mins to fix

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

                    def create_announcement
                        @title = announcement_params[:title]
                        @content = announcement_params[:content]
                        @type = "dashboard"
                        Announcement.create!(:title => @title, :content => @content, :committee_type => @type)
                Severity: Minor
                Found in app/controllers/admin_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