assemblymade/coderwall

View on GitHub

Showing 132 of 189 total issues

Class Team has 128 methods (exceeds 20 allowed). Consider refactoring.
Open

class Team < ActiveRecord::Base
  DEFAULT_HEX_BRAND        = '#343131'
  FEATURED_TEAMS_CACHE_KEY = 'featured_teams_results'
  MAX_TEAM_SCORE           = 400

Severity: Major
Found in app/models/team.rb - About 2 days to fix

    Class Protip has 117 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Protip < ActiveRecord::Base
      extend FriendlyId
      friendly_id :slug_format, :use => :slugged
    
      include Featurable
    Severity: Major
    Found in app/models/protip.rb - About 2 days to fix

      File protip.rb has 778 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'net_validators'
      require 'open-uri'
      require 'cfm'
      require 'scoring'
      require 'search'
      Severity: Major
      Found in app/models/protip.rb - About 1 day to fix

        File team.rb has 600 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'search'
        
        class Team < ActiveRecord::Base
          DEFAULT_HEX_BRAND        = '#343131'
          FEATURED_TEAMS_CACHE_KEY = 'featured_teams_results'
        Severity: Major
        Found in app/models/team.rb - About 1 day to fix

          Class ProtipsController has 56 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ProtipsController < ApplicationController
          
            before_action :access_required, only: [:new, :create, :edit, :update, :destroy, :me]
            before_action :require_skills_first, only: [:new, :create]
            before_action :lookup_protip, only: %i(show edit update destroy upvote tag flag feature delete_tag)
          Severity: Major
          Found in app/controllers/protips_controller.rb - About 1 day to fix

            Method expand has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.expand(audience)
                audience.keys.map(&:to_sym).collect do |target|
            
                  if target == :user_reach
                    user = User.find(audience[target])
            Severity: Minor
            Found in app/structs/audience.rb - About 6 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

            File protips_controller.rb has 429 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class ProtipsController < ApplicationController
            
              before_action :access_required, only: [:new, :create, :edit, :update, :destroy, :me]
              before_action :require_skills_first, only: [:new, :create]
              before_action :lookup_protip, only: %i(show edit update destroy upvote tag flag feature delete_tag)
            Severity: Minor
            Found in app/controllers/protips_controller.rb - About 6 hrs to fix

              Method social_bookmarks has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                def social_bookmarks(user)
                  bookmarks = []
                  bookmarks << social_bookmark('github', "https://github.com/" + user.github) unless user.github.blank?
                  if viewing_self?
                    bookmarks << social_bookmark('linkedin', linkedin_url(user)) unless user.linkedin_token.blank?
              Severity: Minor
              Found in app/helpers/users_helper.rb - About 5 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

              Class Opportunity has 38 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Opportunity < ActiveRecord::Base
                include Tire::Model::Search
                include Tire::Model::Callbacks
                include SearchModule
                include OpportunityMapping
              Severity: Minor
              Found in app/models/opportunity.rb - About 5 hrs to fix

                Class ApplicationController has 37 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class ApplicationController < ActionController::Base
                  protect_from_forgery
                
                  APP_DOMAIN = 'coderwall.com'
                
                
                Severity: Minor
                Found in app/controllers/application_controller.rb - About 4 hrs to fix

                  Method show has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def show
                      #FIXME
                      show_params = params.permit(:job_id, :refresh, :callback, :id, :slug)
                      @team ||= team_from_params(slug: show_params[:slug], id: show_params[:id])
                      return render_404 unless @team
                  Severity: Minor
                  Found in app/controllers/teams_controller.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 show has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def show
                      @user = User.find_by_username!(params[:username])
                  
                      respond_to do |format|
                        format.html do
                  Severity: Minor
                  Found in app/controllers/users_controller.rb - About 3 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 preprocess_query has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def preprocess_query(query_string)
                        query = team = nil
                        unless query_string.nil?
                          query = query_string.dup
                          query.gsub!(/(\d+)\"/, "\\1\\\"") #handle 27" cases
                  Severity: Minor
                  Found in app/models/protip.rb - About 3 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

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

                  class User < ActiveRecord::Base
                    include ActionController::Caching::Fragments
                    include NetValidators
                    include UserApi
                    include UserAward
                  Severity: Minor
                  Found in app/models/user.rb - About 3 hrs to fix

                    Class TeamsController has 27 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class TeamsController < ApplicationController
                      skip_before_action :require_registration, :only => [:accept, :record_exit]
                      before_action :access_required, :except => [:index, :show, :new, :inquiry, :search, :create, :record_exit]
                      before_action :ensure_analytics_access, :only => [:visitors]
                      respond_to :js, :only => [:search, :create, :approve_join, :deny_join]
                    Severity: Minor
                    Found in app/controllers/teams_controller.rb - About 3 hrs to fix

                      Method popular_protips has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def popular_protips(user, protips, from, to)
                          fail 'User is required.' unless user
                          # Skip if this user has already been sent and email for this campaign id.
                          fail "Already sent email to #{user.id} please check Redis SET #{CAMPAIGN_ID}." unless REDIS.sadd(CAMPAIGN_ID, user.id.to_s)
                      
                      
                      Severity: Minor
                      Found in app/mailers/protip_mailer.rb - About 3 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 record_event has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def record_event(action_name, options = {})
                          if !signed_in? || !current_user.admin?
                            options.merge!('mp_name_tag' => cookies[:identity]) unless cookies[:identity].blank?
                            options.merge!('distinct_id' => cookies[:trc]) unless cookies[:trc].blank?
                            unless current_user.nil?
                      Severity: Minor
                      Found in app/controllers/application_controller.rb - About 3 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 search has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def search(query_string, tags =[], options={})
                            query, team, author, bookmarked_by, execution, sorts= preprocess_query(query_string)
                            tags = [] if tags.nil?
                            tags = preprocess_tags(tags)
                            tag_ids = process_tags_for_search(tags)
                      Severity: Minor
                      Found in app/models/protip.rb - About 3 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

                      File protips_helper.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require 'cfm'
                      
                      module ProtipsHelper
                      
                        def protip_search_results_to_render(protips)
                      Severity: Minor
                      Found in app/helpers/protips_helper.rb - About 2 hrs to fix

                        Method execute has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def execute
                              query_criteria, filter_criteria, sort_criteria, facets, context = [@query, @scope, @sort, @facet, @context]
                        
                              @context.tire.search(@options) do
                                query do
                        Severity: Minor
                        Found in app/structs/search.rb - About 2 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

                        Severity
                        Category
                        Status
                        Source
                        Language