assemblymade/coderwall

View on GitHub

Showing 132 of 189 total issues

Avoid deeply nested control flow statements.
Open

      elsif target == :team_followers
        team = Team.find(audience[target])
        expand_followers(team) unless team.nil?
      elsif target == :all
        expand_all_users
Severity: Major
Found in app/structs/audience.rb - About 45 mins to fix

    Method record_exit has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def record_exit(viewer, exit_url, exit_target_type, furthest_scrolled, time_spent)
    Severity: Minor
    Found in app/models/concerns/team_analytics.rb - About 35 mins to fix

      Method search_trending_by_user has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def search_trending_by_user(username, query_string, tags, page, per_page)
      Severity: Minor
      Found in app/models/protip.rb - About 35 mins to fix

        Method search_top_trending_since has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def search_top_trending_since(query, since, tags, page = 1, per_page = 10)
        Severity: Minor
        Found in app/models/protip.rb - About 35 mins to fix

          Method get_jobs_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def get_jobs_for(chosen_location, tag, page, query = nil, remote_allowed = false)
          Severity: Minor
          Found in app/controllers/opportunities_controller.rb - About 35 mins to fix

            Method search has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def self.search(query_string, country, page, per_page, search_type = :query_and_fetch)
            Severity: Minor
            Found in app/models/team.rb - About 35 mins to fix

              Method user_activity has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def user_activity(user, from, to, limit, publish=false)
              Severity: Minor
              Found in app/structs/event.rb - About 35 mins to fix

                Method build_repo_followed_activity! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def build_repo_followed_activity!(refresh=false)
                    Redis.current.zremrangebyrank(followed_repo_key, 0, Time.now.to_i) if refresh
                    epoch_now  = Time.now.to_i
                    first_time = refresh || Redis.current.zcount(followed_repo_key, 0, epoch_now) <= 0
                    links      = GithubOld.new.activities_for(self.github, (first_time ? 20 : 1))
                Severity: Minor
                Found in app/models/concerns/user_github.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

                Method extra_information has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def extra_information(data)
                      extra_info = {}
                      u          = User.find_by_username(data['user']['username']) unless data['user'].nil?
                      extra_info.merge!(user_info(u)) unless u.nil?
                      extra_info.merge!(team_info(u.team)) unless u.nil? or u.team.nil?
                Severity: Minor
                Found in app/structs/event.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

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

                  def create
                    opportunity_create_params = params.require(:opportunity).permit(:name, :team_id, :opportunity_type, :description, :tag_list, :location, :link, :salary, :apply, :remote)
                    @job = Opportunity.new(opportunity_create_params)
                    respond_to do |format|
                      if @job.save
                Severity: Minor
                Found in app/controllers/opportunities_controller.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

                Method protips_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def protips_for(user, how_many=6)
                    if user.last_request_at && user.last_request_at < 5.days.ago
                      protips = Protip.trending_for_user(user).first(how_many)
                      protips += Protip.trending.first(how_many-protips.count) if protips.count < how_many
                    else
                Severity: Minor
                Found in app/mailers/weekly_digest_mailer.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

                Method get_team_and_job_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.get_team_and_job_for(user)
                    if user.team.try(:hiring?)
                      [user.team, user.team.jobs.sample]
                    else
                      teams = teams_for_user(user)
                Severity: Minor
                Found in app/mailers/protip_mailer.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

                Method destination_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def destination_url
                    if session[:return_to]
                      session.delete(:return_to)
                    elsif signed_in?
                      if current_user.oldest_achievement_since_last_visit
                Severity: Minor
                Found in app/controllers/application_controller.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

                Method trending_topics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def trending_topics
                      trending_protips = search(nil, [], page: 1, per_page: 100)
                
                      unless trending_protips.respond_to?(:errored?) and trending_protips.errored?
                        static_trending = ENV['FEATURED_TOPICS'].split(",").map(&:strip).map(&:downcase) unless ENV['FEATURED_TOPICS'].blank?
                Severity: Minor
                Found in app/models/protip.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

                Method topic_protips_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def topic_protips_path(topic)
                    user = topic.is_a?(Array) ? (topic.size == 1 ? topic.first : nil) : topic
                    if User.exists?(username: user)
                      user_protips_path(user)
                    else
                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

                Method for_omniauth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def for_omniauth(auth)
                      if user = find_with_oauth(auth)
                        user.apply_oauth(auth)
                        user.save! if user.changed?
                      else
                Severity: Minor
                Found in app/models/concerns/user_oauth.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

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

                  def show
                    @team = Team.find(params[:id])
                    invitation_failed! unless @team.has_user_with_referral_token?(params[:r])
                    store_location! unless signed_in?
                    session[:referred_by] = params[:r]
                Severity: Minor
                Found in app/controllers/invitations_controller.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

                Method perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def perform(spammable)
                    return if Rails.env.test? || Rails.env.development?
                    begin
                      thing_to_analyze = spammable['klass'].classify.constantize.find(spammable['id'])
                
                
                Severity: Minor
                Found in app/jobs/analyze_spam_job.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

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

                  def update
                    update_params = params.permit(:id, :_id, :job_id, :slug)
                    update_team_params = params.require(:team).permit!
                    @section_id = (params.permit(:section_id) || {})[:section_id]
                
                
                Severity: Minor
                Found in app/controllers/teams_controller.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

                Method follow has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def follow
                    # TODO move to concern
                    @team = if params[:id].present? && (params[:id].to_i rescue nil)
                              Team.find(params[:id].to_i)
                            else
                Severity: Minor
                Found in app/controllers/teams_controller.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

                Severity
                Category
                Status
                Source
                Language