assemblymade/coderwall

View on GitHub

Showing 132 of 189 total issues

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

  def create
    @user = User.for_omniauth(oauth)

    ucp = user_create_params.dup

Severity: Minor
Found in app/controllers/users_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 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_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 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 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 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 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 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 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

              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 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 visitors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def visitors
                  since = is_admin? ? 0 : 2.weeks.ago.to_i
                  full = is_admin? && params[:full] == 'true'
                  @visitors = @team.aggregate_visitors(since).reject { |visitor| visitor[:user] && @team.on_team?(visitor[:user]) }
                  @visitors = @visitors.first(75) if !is_admin? || !full
              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 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 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 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 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 get_team_and_job_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def 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/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

              Function blur has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  blur: function (strength) {
                      this.context.globalAlpha = 0.5; // Higher alpha made it more smooth
                      // Add blur layers by strength to x and y
                      // 2 made it a bit faster without noticeable quality loss
                      for (var y = -strength; y <= strength; y += 2) {
              Severity: Minor
              Found in app/assets/javascripts/blur.js - 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