camdub/Internships

View on GitHub
app/controllers/internships_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Method index has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @internships = Internship.all

    # Very inefficient when users table has thousands of rows.
    respond_to do |format|
Severity: Minor
Found in app/controllers/internships_controller.rb - About 1 day 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 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    @internship = Internship.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
Severity: Major
Found in app/controllers/internships_controller.rb - About 2 hrs to fix

    Method index has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        @internships = Internship.all
    
        # Very inefficient when users table has thousands of rows.
        respond_to do |format|
    Severity: Minor
    Found in app/controllers/internships_controller.rb - About 1 hr to fix

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

        def show
          @internship = Internship.find(params[:id])
      
          respond_to do |format|
            format.html # show.html.erb
      Severity: Minor
      Found in app/controllers/internships_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

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

        def create
          @internship = Internship.new(params[:internship])
          
          respond_to do |format|
            if @internship.save
      Severity: Major
      Found in app/controllers/internships_controller.rb and 23 other locations - About 1 hr to fix
      app/controllers/academic_contacts_controller.rb on lines 53..62
      app/controllers/academic_focus_types_controller.rb on lines 49..58
      app/controllers/academic_focuses_controller.rb on lines 54..63
      app/controllers/colleges_controller.rb on lines 49..58
      app/controllers/countries_controller.rb on lines 49..58
      app/controllers/departments_controller.rb on lines 49..58
      app/controllers/financial_assistance_option_types_controller.rb on lines 49..58
      app/controllers/financial_assistance_options_controller.rb on lines 51..60
      app/controllers/industries_controller.rb on lines 49..58
      app/controllers/internship_instances_controller.rb on lines 49..58
      app/controllers/languages_controller.rb on lines 51..60
      app/controllers/locations_controller.rb on lines 51..60
      app/controllers/long_term_goals_controller.rb on lines 51..60
      app/controllers/provider_contacts_controller.rb on lines 59..68
      app/controllers/provider_types_controller.rb on lines 49..58
      app/controllers/providers_controller.rb on lines 52..61
      app/controllers/roles_controller.rb on lines 42..51
      app/controllers/semesters_controller.rb on lines 51..60
      app/controllers/states_controller.rb on lines 49..58
      app/controllers/students_controller.rb on lines 42..51
      app/controllers/tags_controller.rb on lines 51..60
      app/controllers/tasks_controller.rb on lines 51..60
      app/controllers/users_controller.rb on lines 64..72

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

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

        def update
          @internship = Internship.find(params[:id])
          respond_to do |format|
            if @internship.update_attributes(params[:internship])
              format.html { redirect_to(@internship, :notice => 'Internship was successfully updated.') }
      Severity: Major
      Found in app/controllers/internships_controller.rb and 24 other locations - About 1 hr to fix
      app/controllers/academic_contacts_controller.rb on lines 69..78
      app/controllers/academic_focus_types_controller.rb on lines 65..74
      app/controllers/academic_focuses_controller.rb on lines 70..79
      app/controllers/colleges_controller.rb on lines 65..74
      app/controllers/countries_controller.rb on lines 65..74
      app/controllers/departments_controller.rb on lines 65..74
      app/controllers/fields_controller.rb on lines 70..79
      app/controllers/financial_assistance_option_types_controller.rb on lines 65..74
      app/controllers/financial_assistance_options_controller.rb on lines 67..76
      app/controllers/industries_controller.rb on lines 65..74
      app/controllers/internship_instances_controller.rb on lines 65..74
      app/controllers/languages_controller.rb on lines 67..76
      app/controllers/locations_controller.rb on lines 67..76
      app/controllers/long_term_goals_controller.rb on lines 67..76
      app/controllers/provider_contacts_controller.rb on lines 75..84
      app/controllers/provider_types_controller.rb on lines 65..74
      app/controllers/providers_controller.rb on lines 68..77
      app/controllers/roles_controller.rb on lines 58..67
      app/controllers/semesters_controller.rb on lines 67..76
      app/controllers/states_controller.rb on lines 65..74
      app/controllers/students_controller.rb on lines 58..67
      app/controllers/tags_controller.rb on lines 67..76
      app/controllers/tasks_controller.rb on lines 67..76
      app/controllers/users_controller.rb on lines 79..89

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

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

        def new
          @internship = Internship.new
          
          @internship.user = @current_user if @internship.user == nil
          
      Severity: Minor
      Found in app/controllers/internships_controller.rb and 2 other locations - About 15 mins to fix
      app/controllers/long_term_goals_controller.rb on lines 33..40
      app/controllers/short_term_goals_controller.rb on lines 58..65

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

      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