GAKUEngine/gaku

View on GitHub

Showing 69 of 69 total issues

Method change has 547 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def change
    create_table :gaku_badge_types do |t|
      t.string   :name
      t.string   :code
      t.text     :description
Severity: Major
Found in core/db/migrate/20131025073352_gaku_core.rb - About 2 days to fix

    File 20131025073352_gaku_core.rb has 553 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'gaku/migrations'
    
    class GakuCore < ActiveRecord::Migration[4.2]
    
      include Gaku::Migrations
    Severity: Major
    Found in core/db/migrate/20131025073352_gaku_core.rb - About 1 day to fix

      Method grading has 151 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def grading
            def init_variables
              @course = Course.find(params[:course_id])
              @exam = Exam.find(params[:id])
              @students = @course.students
      Severity: Major
      Found in core/app/controllers/gaku/courses/exams_controller.rb - About 6 hrs to fix

        File schema.rb has 411 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        ActiveRecord::Schema.define(version: 20121013102921) do
        
          create_table 'gaku_addresses', force: true do |t|
            t.string   'address1'
            t.string   'address2'
        Severity: Minor
        Found in core/db/schema.rb - About 5 hrs to fix

          Method up has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def up
              create_table :gaku_attendance_types do |t|
                t.string   :name
                t.string   :color_code
                t.boolean  :counted_absent
          Severity: Minor
          Found in core/db/migrate/20131014065028_translations.rb - About 1 hr to fix

            Method method_ratio has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                    def method_ratio
                      default_grade_level_deviation = [100, 66, 62, 58, 55, 50, 45, 37, 0]
                      @rank_level = [15, 20]
            
                      # default_grade_level_percent = [5, 5, 10, 10, 30, 10, 100]
            Severity: Minor
            Found in core/app/controllers/gaku/courses/exams_controller.rb - About 1 hr 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_state has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def find_state
                result = nil
                Carmen.i18n_backend.available_locales.each do |locale|
                  Carmen.i18n_backend.locale = locale
                  Carmen::Country.all.each do |country|
            Severity: Minor
            Found in api/app/services/gaku/api/address_create_service.rb - About 1 hr 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

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

                def setup_assets
                  @lib_name = 'gaku'
                  %w( javascripts stylesheets images ).each do |path|
                    empty_directory "app/assets/#{path}/gaku/frontend" if defined? Gaku::Frontend || Rails.env.test?
                    empty_directory "app/assets/#{path}/gaku/admin" if defined? Gaku::Admin || Rails.env.test?
            Severity: Major
            Found in core/lib/generators/gaku/docker/docker_generator.rb and 1 other location - About 1 hr to fix
            core/lib/generators/gaku/install/install_generator.rb on lines 40..54

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

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

                def setup_assets
                  @lib_name = 'gaku'
                  %w( javascripts stylesheets images ).each do |path|
                    empty_directory "app/assets/#{path}/gaku/frontend" if defined? Gaku::Frontend || Rails.env.test?
                    empty_directory "app/assets/#{path}/gaku/admin" if defined? Gaku::Admin || Rails.env.test?
            Severity: Major
            Found in core/lib/generators/gaku/install/install_generator.rb and 1 other location - About 1 hr to fix
            core/lib/generators/gaku/docker/docker_generator.rb on lines 45..59

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

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

                  def lookup(locale, key, scope = [], options = {})
                    init_translations unless initialized?
                    keys = I18n.normalize_keys(locale, key, scope, options[:separator])
            
                    puts "I18N keys: #{keys}"  if ENV['I18N_DEBUG']
            Severity: Minor
            Found in core/config/initializers/i18n.rb - About 1 hr 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 student_names has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def student_names(options = {})
                  @names_preset ||= Gaku::Preset.names
                  preset = @names_preset
            
                  if options[:without_formating]
            Severity: Minor
            Found in core/app/decorators/gaku/person_decorator.rb - About 1 hr 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

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

                  def call
                    if user
                      secret = SecureRandom.hex(64)
                      $redis.set("token:#{jti}", secret, ex: 20.minutes)
                      {
            Severity: Major
            Found in api/app/services/gaku/api/authenticate_user.rb and 1 other location - About 1 hr to fix
            api/app/services/gaku/api/refresh_authenticate_user.rb on lines 13..20

            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

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

                  def call
                    if user
                      secret = SecureRandom.hex(64)
                      $redis.set("token:#{jti}", secret, ex: 20.minutes)
                      {
            Severity: Major
            Found in api/app/services/gaku/api/refresh_authenticate_user.rb and 1 other location - About 1 hr to fix
            api/app/services/gaku/api/authenticate_user.rb on lines 14..21

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

              module Api
                module V1
                  module Exams
                    class ExamPortionsController < BaseController
                      skip_before_action :authenticate_request
            api/app/controllers/gaku/api/v1/exams/exam_portions/exam_portion_scores_controller.rb on lines 3..22

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

            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

                module V1
                  module Exams
                    module ExamPortions
                      class ExamPortionScoresController < BaseController
                        skip_before_action :authenticate_request
            api/app/controllers/gaku/api/v1/exams/exam_portions_controller.rb on lines 2..21

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

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

              module Api
                module V1
                  module Students
                    class ExamSessionsController < BaseController
            
            
            api/app/controllers/gaku/api/v1/students/class_groups_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/courses_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/extracurricular_activities_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/guardians_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/courses_controlle.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/exams_controller.rb on lines 2..20

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

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

              module Api
                module V1
                  module Syllabuses
                    class ExamsController < BaseController
            
            
            api/app/controllers/gaku/api/v1/students/class_groups_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/courses_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/exam_sessions_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/extracurricular_activities_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/guardians_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/courses_controlle.rb on lines 2..20

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

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

              module Api
                module V1
                  module Students
                    class ExtracurricularActivitiesController < BaseController
            
            
            api/app/controllers/gaku/api/v1/students/class_groups_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/courses_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/exam_sessions_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/guardians_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/courses_controlle.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/exams_controller.rb on lines 2..20

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

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

              module Api
                module V1
                  module Students
                    class GuardiansController < BaseController
            
            
            api/app/controllers/gaku/api/v1/students/class_groups_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/courses_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/exam_sessions_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/extracurricular_activities_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/courses_controlle.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/exams_controller.rb on lines 2..20

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

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

              module Api
                module V1
                  module Students
                    class ClassGroupsController < BaseController
            
            
            api/app/controllers/gaku/api/v1/students/courses_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/exam_sessions_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/extracurricular_activities_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/students/guardians_controller.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/courses_controlle.rb on lines 2..20
            api/app/controllers/gaku/api/v1/syllabuses/exams_controller.rb on lines 2..20

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

            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

            Severity
            Category
            Status
            Source
            Language