assemblymade/coderwall

View on GitHub
app/controllers/teams_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

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

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

    File teams_controller.rb has 251 lines of code (exceeds 250 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 2 hrs to fix

      Method accept has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def accept
          apply_cache_buster
      
          accept_params = params.permit(:id, :r, :email)
      
      
      Severity: Minor
      Found in app/controllers/teams_controller.rb - About 55 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 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 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

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

        def approve_join
          approve_join_params = params.permit(:id, :user_id)
      
          @team = Team.find(approve_join_params[:id])
          return head(:forbidden) unless @team && @team.admin?(current_user)
      Severity: Minor
      Found in app/controllers/teams_controller.rb and 1 other location - About 35 mins to fix
      app/controllers/teams_controller.rb on lines 258..266

      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 34.

      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 2 locations. Consider refactoring.
      Open

        def deny_join
          deny_join_params = params.permit(:id, :user_id)
      
          @team = Team.find(deny_join_params[:id])
          return head(:forbidden) unless @team && @team.admin?(current_user)
      Severity: Minor
      Found in app/controllers/teams_controller.rb and 1 other location - About 35 mins to fix
      app/controllers/teams_controller.rb on lines 247..255

      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 34.

      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 2 locations. Consider refactoring.
      Open

          respond_to do |format|
            format.json { render json: { dom_id: dom_id(@team), following: current_user.following_team?(@team) } }
            format.js { render json: { dom_id: dom_id(@team), following: current_user.following_team?(@team) } }
      Severity: Minor
      Found in app/controllers/teams_controller.rb and 1 other location - About 30 mins to fix
      app/controllers/follows_controller.rb on lines 33..35

      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 32.

      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

      There are no issues that match your filters.

      Category
      Status