GAKUEngine/gaku

View on GitHub

Showing 69 of 69 total issues

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

  module Api
    module V1
      module Students
        class CoursesController < BaseController

api/app/controllers/gaku/api/v1/students/class_groups_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

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

  module Api
    module V1
      module Sylabuses
        class CoursesController < 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/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

Method weight_calculate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def weight_calculate
      if (exam.total_weight_except(self) + weight) > 100
        last = exam.exam_portions.last

        interval = weight - weight_was
Severity: Minor
Found in core/app/models/gaku/exam_portion.rb - About 45 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 setup_assets has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
Found in core/lib/generators/gaku/docker/docker_generator.rb - About 45 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 setup_assets has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
Found in core/lib/generators/gaku/install/install_generator.rb - About 45 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 process_js_gaku_action has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def process_js_gaku_action(action, method = 'GET', params = nil, session = nil, flash = nil)
Severity: Minor
Found in core/lib/gaku/testing/controller_helpers.rb - About 35 mins to fix

    Method api_process has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def api_process(action, params = {}, session = nil, flash = nil, method = 'get')
    Severity: Minor
    Found in core/lib/gaku/testing/controller_helpers.rb - About 35 mins to fix

      Method process_gaku_action has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def process_gaku_action(action, method = 'GET', parameters = nil, session = nil, flash = nil)
      Severity: Minor
      Found in core/lib/gaku/testing/controller_helpers.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def initialize(grading_methods, student, exam, gradable_scope, collection_students = nil)
        Severity: Minor
        Found in core/lib/gaku/grading/single/calculations.rb - About 35 mins to fix

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

            create_table 'gaku_assignments', force: true do |t|
              t.string   'name'
              t.text     'description'
              t.integer  'max_score'
              t.integer  'syllabus_id'
          Severity: Minor
          Found in core/db/schema.rb and 2 other locations - About 35 mins to fix
          core/db/schema.rb on lines 61..69
          core/db/schema.rb on lines 450..458

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

          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

            create_table 'gaku_syllabuses', force: true do |t|
              t.string   'name'
              t.string   'code'
              t.text     'description'
              t.integer  'credits'
          Severity: Minor
          Found in core/db/schema.rb and 2 other locations - About 35 mins to fix
          core/db/schema.rb on lines 39..47
          core/db/schema.rb on lines 61..69

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

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

                def set_student_exams_total_scores_and_set_exams_average
                  @exams.each do |exam|
                    @students.each do |student|
                      # 素点用と得点用変数の初期化 --------
                      @student_exams_total_score[:raw][exam.id][student.id] = 0.0
          Severity: Minor
          Found in core/app/controllers/gaku/courses/exams_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 3 locations. Consider refactoring.
          Open

            create_table 'gaku_attendances', force: true do |t|
              t.string   'reason'
              t.text     'description'
              t.integer  'attendancable_id'
              t.string   'attendancable_type'
          Severity: Minor
          Found in core/db/schema.rb and 2 other locations - About 35 mins to fix
          core/db/schema.rb on lines 39..47
          core/db/schema.rb on lines 450..458

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

          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

              create_table :gaku_external_school_records do |t|
                t.date     :beginning
                t.date     :ending
                t.string   :student_id_number
                t.integer  :absences
          Severity: Minor
          Found in core/db/migrate/20131025073352_gaku_core.rb and 1 other location - About 35 mins to fix
          core/db/migrate/20131025073352_gaku_core.rb on lines 185..195

          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

              create_table :gaku_exam_portions do |t|
                t.string   :name
                t.float    :max_score
                t.float    :weight
                t.integer  :problem_count
          Severity: Minor
          Found in core/db/migrate/20131025073352_gaku_core.rb and 1 other location - About 35 mins to fix
          core/db/migrate/20131025073352_gaku_core.rb on lines 244..254

          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

            module Api
              module V1
                module Students
                  class StudentGuardiansController < BaseController
          
          
          api/app/controllers/gaku/api/v1/users/user_roles_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 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

            module Api
              module V1
                module Users
                  class UserRolesController < BaseController
                    before_action :set_role
          Severity: Minor
          Found in api/app/controllers/gaku/api/v1/users/user_roles_controller.rb and 1 other location - About 35 mins to fix
          api/app/controllers/gaku/api/v1/students/student_guardians_controller.rb on lines 2..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 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

            included do
              has_many :addresses, as: :addressable
              has_one :primary_address, -> { where(primary: true) }, class_name: 'Gaku::Address', as: :addressable
          
              # def primary_address
          Severity: Minor
          Found in core/app/models/concerns/addresses.rb and 1 other location - About 30 mins to fix
          core/app/models/concerns/contacts.rb on lines 4..13

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

          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
                class EnrollmentStatusesController < BaseController
          
                  skip_before_action :authenticate_request
          api/app/controllers/gaku/api/v1/contact_types_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 33.

          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

            included do
              has_many :contacts, as: :contactable
              has_one :primary_contact, -> { where(primary: true) }, class_name: 'Gaku::Contact', as: :contactable
          
              # def primary_contact
          Severity: Minor
          Found in core/app/models/concerns/contacts.rb and 1 other location - About 30 mins to fix
          core/app/models/concerns/addresses.rb on lines 4..15

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

          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