media3-0/apki.org

View on GitHub
spec/controllers/course/courses_spec.rb

Summary

Maintainability
C
1 day
Test Coverage

File courses_spec.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

describe Course::CourseDataController, type: :controller do
  render_views

Severity: Minor
Found in spec/controllers/course/courses_spec.rb - About 2 hrs to fix

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

      it 'User or teacher cannot destroy course' do
        session[:user_id] = @user.id.to_s
    
        course = Course::CourseDatum.create!(data: @data)
    
    
    Severity: Major
    Found in spec/controllers/course/courses_spec.rb and 2 other locations - About 2 hrs to fix
    spec/controllers/course/exercises_spec.rb on lines 113..125
    spec/controllers/course/quizzes_spec.rb on lines 113..125

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

    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

        json_response.each do |course_temp|
          expect(course_temp['data']['lessonCurrent']).to eq lessons[1].id.to_s
          expect(course_temp['data']['lessonsPassed'].count).to eq 1
          expect(course_temp['data']['userInside']).to eq true
          expect(course_temp['data']['userFinished']).to eq false
    Severity: Major
    Found in spec/controllers/course/courses_spec.rb and 2 other locations - About 55 mins to fix
    spec/controllers/course/courses_spec.rb on lines 253..257
    spec/controllers/course/courses_spec.rb on lines 299..303

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

    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

        json_response.each do |course_temp|
          expect(course_temp['data']['lessonCurrent']).to eq lessons[2].id.to_s
          expect(course_temp['data']['lessonsPassed'].count).to eq 2
          expect(course_temp['data']['userInside']).to eq true
          expect(course_temp['data']['userFinished']).to eq false
    Severity: Major
    Found in spec/controllers/course/courses_spec.rb and 2 other locations - About 55 mins to fix
    spec/controllers/course/courses_spec.rb on lines 253..257
    spec/controllers/course/courses_spec.rb on lines 276..280

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

    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

        json_response.each do |course_temp|
          expect(course_temp['data']['lessonCurrent']).to eq lessons[0].id.to_s
          expect(course_temp['data']['lessonsPassed'].count).to eq 0
          expect(course_temp['data']['userInside']).to eq true
          expect(course_temp['data']['userFinished']).to eq false
    Severity: Major
    Found in spec/controllers/course/courses_spec.rb and 2 other locations - About 55 mins to fix
    spec/controllers/course/courses_spec.rb on lines 276..280
    spec/controllers/course/courses_spec.rb on lines 299..303

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

    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

      it 'Admin can destroy course' do
        session[:user_id] = @admin.id.to_s
    
        course = Course::CourseDatum.create!(data: @data)
    
    
    Severity: Major
    Found in spec/controllers/course/courses_spec.rb and 2 other locations - About 50 mins to fix
    spec/controllers/course/exercises_spec.rb on lines 103..110
    spec/controllers/course/quizzes_spec.rb on lines 103..110

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

    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

      it 'Admin can update course' do
        session[:user_id] = @admin.id.to_s
    
        course = Course::CourseDatum.create!
    
    
    Severity: Minor
    Found in spec/controllers/course/courses_spec.rb and 1 other location - About 45 mins to fix
    spec/controllers/course/achievements_spec.rb on lines 81..93

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

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

      it 'Not logged user cannot access to POST courses' do
        post :create, format: :json
        expect(response.status).to eq 401
        patch :update, format: :json, id: 'asdf'
        expect(response.status).to eq 401
    Severity: Major
    Found in spec/controllers/course/courses_spec.rb and 4 other locations - About 45 mins to fix
    spec/controllers/course/achievements_spec.rb on lines 201..207
    spec/controllers/course/exercises_spec.rb on lines 257..263
    spec/controllers/course/lessons_spec.rb on lines 176..182
    spec/controllers/course/quizzes_spec.rb on lines 240..246

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

    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

    Identical blocks of code found in 6 locations. Consider refactoring.
    Open

      before(:all) do
        @admin = User.create!(nickname: 'test_admin', uid: 'asdf', account_type: :admin)
        @user = User.create!(nickname: 'test_student', uid: 'zxcv', account_type: :student)
        @teacher = User.create!(nickname: 'test_teacher', uid: 'zxcv', account_type: :teacher)
    
    
    Severity: Major
    Found in spec/controllers/course/courses_spec.rb and 5 other locations - About 40 mins to fix
    spec/controllers/course/achievements_spec.rb on lines 6..11
    spec/controllers/course/exercises_spec.rb on lines 6..11
    spec/controllers/course/lessons_spec.rb on lines 6..11
    spec/controllers/course/quizzes_spec.rb on lines 6..11
    spec/controllers/course/user_course_spec.rb on lines 4..9

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

    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