assemblymade/coderwall

View on GitHub

Showing 189 of 189 total issues

Similar blocks of code found in 8 locations. Consider refactoring.
Open

    const_set "MostComplete#{year}", Class.new(BadgeBase) {
      describe "KO Complete",
               skill:       'Node.js',
               description: "Won the most complete app in the #{year} Node Knockout",
               for:         "winning the most complete app in the #{year} Node Knockout",
Severity: Major
Found in app/badges/node_knockout.rb and 7 other locations - About 25 mins to fix
app/badges/node_knockout.rb on lines 149..156
app/badges/node_knockout.rb on lines 158..165
app/badges/node_knockout.rb on lines 167..174
app/badges/node_knockout.rb on lines 176..183
app/badges/node_knockout.rb on lines 185..192
app/badges/node_knockout.rb on lines 194..201
app/badges/node_knockout.rb on lines 203..210

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def avatar_url_for(oauth)
      if oauth[:extra] && oauth[:extra][:raw_info] && oauth[:extra][:raw_info][:gravatar_id]
        "https://secure.gravatar.com/avatar/#{oauth[:extra][:raw_info][:gravatar_id]}"
      elsif oauth[:info]
        if oauth['provider'] == 'twitter'
Severity: Minor
Found in app/models/concerns/user_oauth.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

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

  def linkedin_url(user)
    if !user.linkedin_public_url.blank?
      user.linkedin_public_url
    elsif !user.linkedin.blank?
      "http://www.linkedin.com/in/#{user.linkedin}"
Severity: Minor
Found in app/helpers/users_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 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    # strong_parameters will intentionally fail if a key is present but has an empty hash. :(
    update_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 find_with_oauth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def find_with_oauth(oauth)
      case oauth[:provider]
        when 'github'
          (oauth[:uid] ? find_by_github_id(oauth[:uid]) : find_by_github(oauth[:info][:nickname]))
        when 'linkedin'
Severity: Minor
Found in app/models/concerns/user_oauth.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

Similar blocks of code found in 8 locations. Consider refactoring.
Open

    const_set "Judge#{year}", Class.new(BadgeBase) {
      describe "KO Judge",
               skill:       'Node.js',
               description: "Official Judge of the #{year} Node Knockout",
               for:         "judging the #{year} Node Knockout.",
Severity: Major
Found in app/badges/node_knockout.rb and 7 other locations - About 25 mins to fix
app/badges/node_knockout.rb on lines 149..156
app/badges/node_knockout.rb on lines 167..174
app/badges/node_knockout.rb on lines 176..183
app/badges/node_knockout.rb on lines 185..192
app/badges/node_knockout.rb on lines 194..201
app/badges/node_knockout.rb on lines 203..210
app/badges/node_knockout.rb on lines 212..219

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

  def create
    redirect_to teamname_path(slug: @team.slug) if @plan.free?

    @account = @team.build_account(account_params)

Severity: Minor
Found in app/controllers/accounts_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 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 generate_event has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_event(event_type, audience, data={}, drip_rate=:immediately)
      data.merge!({ event_type: event_type }.with_indifferent_access)
      data = { version: VERSION, event_id: Time.now.utc.to_i }.with_indifferent_access.merge(data)
      data.deep_merge!(extra_information(data))
      drip_rate = :immediately if drip_rate.nil?
Severity: Minor
Found in app/structs/event.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

Similar blocks of code found in 8 locations. Consider refactoring.
Open

    const_set "MostUseful#{year}", Class.new(BadgeBase) {
      describe "KO Utility",
               skill:       'Node.js',
               description: "Won the most useful app in the #{year} Node Knockout",
               for:         "winning the most useful app in the #{year} Node Knockout",
Severity: Major
Found in app/badges/node_knockout.rb and 7 other locations - About 25 mins to fix
app/badges/node_knockout.rb on lines 149..156
app/badges/node_knockout.rb on lines 158..165
app/badges/node_knockout.rb on lines 167..174
app/badges/node_knockout.rb on lines 176..183
app/badges/node_knockout.rb on lines 185..192
app/badges/node_knockout.rb on lines 203..210
app/badges/node_knockout.rb on lines 212..219

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

    const_set "MostInnovative#{year}", Class.new(BadgeBase) {
      describe "KO Innovation",
               skill:       'Node.js',
               description: "Won the most innovative app in the #{year} Node Knockout",
               for:         "winning the most innovative app in the #{year} Node Knockout",
Severity: Major
Found in app/badges/node_knockout.rb and 7 other locations - About 25 mins to fix
app/badges/node_knockout.rb on lines 149..156
app/badges/node_knockout.rb on lines 158..165
app/badges/node_knockout.rb on lines 167..174
app/badges/node_knockout.rb on lines 176..183
app/badges/node_knockout.rb on lines 185..192
app/badges/node_knockout.rb on lines 194..201
app/badges/node_knockout.rb on lines 212..219

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def visitors(since = 0)
      detailed_visitors = self.detailed_visitors
      first_detailed_visit = detailed_visitors.last.nil? ? updated_at : detailed_visitors.first[:visited_at]
      self.detailed_visitors(since) + simple_visitors(since == 0 ? first_detailed_visit.to_i : since)
    end
Severity: Minor
Found in app/models/concerns/team_analytics.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 images has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def images
    if self.new_record?
      self.links.select { |link| ProtipLink.is_image? link }
    else
      if protip_links.loaded?
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

Similar blocks of code found in 8 locations. Consider refactoring.
Open

    const_set "Champion#{year}", Class.new(BadgeBase) {
      describe "KO Champion",
               skill:       'Node.js',
               description: "Won first place in the #{year} Node Knockout",
               for:         "winning first place in the #{year} Node Knockout.",
Severity: Major
Found in app/badges/node_knockout.rb and 7 other locations - About 25 mins to fix
app/badges/node_knockout.rb on lines 149..156
app/badges/node_knockout.rb on lines 158..165
app/badges/node_knockout.rb on lines 176..183
app/badges/node_knockout.rb on lines 185..192
app/badges/node_knockout.rb on lines 194..201
app/badges/node_knockout.rb on lines 203..210
app/badges/node_knockout.rb on lines 212..219

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

  def <=> y
    val = team_size_threshold <=> y.team_size_threshold
    return val unless val == 0

    val = score <=> y.score
Severity: Minor
Found in app/models/team.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