assemblymade/coderwall

View on GitHub

Showing 132 of 189 total issues

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

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

  def associate_event_fact(fact)
    if fact.tagged?('event')
      tokenized_tags = fact.tags.map { |t| Skill.tokenize(t) }
      if tokenized_tags.include?(tokenized)
        if fact.tagged?('spoke')
Severity: Minor
Found in app/models/skill.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

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

Avoid too many return statements within this method.
Open

      return photos['Nowhere']
Severity: Major
Found in app/structs/location_photo.rb - About 30 mins to fix

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

      def date
        date_params = params.permit(:date, :query, :page, :per_page)
    
        date = Date.current if date_params[:date].downcase == "today"
        date = Date.current.advance(days: -1) if params[:date].downcase == "yesterday"
    Severity: Minor
    Found in app/controllers/protips_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

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

      def destroy
        self_removal = current_user.id == params[:id]
        return head(:forbidden) unless signed_in? && (@team.admin?(current_user) || self_removal)
        @team.members.find_by_user_id!(params[:id]).destroy
    
    
    Severity: Minor
    Found in app/controllers/members_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

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

        def search_trending_by_team(team_id, query_string, page, per_page)
          options = { page: page, per_page: per_page }
          force_index_commit = Protip.tire.index.refresh if Rails.env.test?
          query = "team.name:#{team_id.to_s}"
          query              += " #{query_string}" unless query_string.nil?
    Severity: Minor
    Found in app/models/protip.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

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

      def generate_event(options={})
        event_type = event_type(options)
        data       = to_event_hash(options)
        GenerateEventJob.perform_async(event_type, event_audience(event_type), data, 1.minute)
    
    
    Severity: Minor
    Found in app/models/comment.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

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

        def reverse_geocode(ip_address)
          uri = URI::HTTP.build(scheme: 'http',
                                host: 'geoip.maxmind.com',
                                path: @service_path,
                                query: URI.encode_www_form(l: @license,
    Severity: Minor
    Found in lib/reverse_geocoder.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

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

      def delivered
        Rails.logger.info("Mailgun Delivered: #{params.inspect}")
        if mailgun?(ENV['MAILGUN_API_KEY'], params['token'], params['timestamp'], params['signature'])
          if params[:event] = "delivered"
            user = User.where(email: params[:recipient]).first
    Severity: Minor
    Found in app/controllers/emails_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

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

      def perform(user_id)
        begin
          user = User.find(user_id)
          return if user.active?
    
    
    Severity: Minor
    Found in app/workers/user_activate_worker.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

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

        def tag_when_project_matches(tag_name, matcher, readme_matcher, language = nil)
          if language && dominant_language.downcase == language.downcase
            if field_matches?(self.name, matcher) ||
                field_matches?(self.description, matcher) ||
                (readme_matcher && dominant_language_percentage > LANGUAGE_THRESHOLD_FOR_README && readme_matches?(readme_matcher))
    Severity: Minor
    Found in lib/repository.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

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

      def award
    
        award_params = params.permit(:badge, :twitter, :linkedin, :github, :date)
    
        provider = pick_a_provider(award_params)
    Severity: Minor
    Found in app/controllers/achievements_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

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

      def create
        create_params = if params[:protip] && params[:protip].keys.present?
                          params.require(:protip).permit(:title, :body, :user_id, :topic_list)
                        else
                          {}
    Severity: Minor
    Found in app/controllers/protips_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

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

      def message_to_create_ehanced_team
        if signed_in? && !current_user.team.nil?
          "Is #{current_user.team.name} awesome and hiring? Enhance your team's profile here. Hiring teams are visited by 7X more developers" unless current_user.team.try(:hiring?) == true
        else
          "Have an amazing team that is hiring? Setup your team's profile."
    Severity: Minor
    Found in app/helpers/teams_helper.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

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

      def my_protips?(topics)
        topics.map do |topic|
          if Protip::USER_SCOPE_REGEX[:author] =~ topic || Protip::USER_SCOPE_REGEX[:bookmark] =~ topic
            return true
          end
    Severity: Minor
    Found in app/helpers/protips_helper.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

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

          def self.import_from_follows(description, link, date, owner)
            if protiplink = ProtipLink.find_by_encoded_url(link)
              protiplink.protip.upvote_by(owner, owner.tracking_code, Protip::DEFAULT_IP_ADDRESS) unless protiplink.protip.nil?
            else
              language = GithubOld.new.predominant_repo_lanugage_for_link(link)
    Severity: Minor
    Found in lib/importers.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

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

      def perform(process_type, like_id)
        like = Like.find(like_id)
        case process_type
          when 'associate_to_user'
            begin
    Severity: Minor
    Found in app/jobs/process_like_job.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

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

      def already_voted?(voter, tracking, ip_address)
        existing_upvote = likes.where(user_id: voter.id).first unless voter.nil?
        existing_upvote = likes.where(tracking_code: tracking).first if existing_upvote.nil? and tracking
        existing_upvote = likes.where(ip_address: ip_address).first if existing_upvote.nil? and voter.nil? and (tracking.nil? || !User.exists?(tracking_code: tracking))
    
    
    Severity: Minor
    Found in app/models/protip.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