Showing 17 of 17 total issues

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

    split[
      pipe[ ExtractItems[:kosapi_people, from: :course_events, attr: :creator], ConvertPeople, Sync[Person] ],
      pipe[ ExtractItems[:kosapi_courses, from: :course_events, attr: :course], ConvertCourses, Sync[Course] ],
      pipe[ ExtractItems[:kosapi_rooms, from: :course_events, attr: :room], ConvertRooms, Sync[Room] ],
      Sync[Event, matching_attributes: [:faculty, :source_type, :source_id, :absolute_sequence_number]]
Severity: Major
Found in app/interactors/import_course_events.rb and 1 other location - About 1 hr to fix
app/interactors/import_exams.rb on lines 18..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 54.

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

    split[
      pipe[ ExtractItems[:kosapi_people, from: :exams, attr: :examiner], ConvertPeople, Sync[Person] ],
      pipe[ ExtractItems[:kosapi_courses, from: :exams, attr: :course], ConvertCourses, Sync[Course] ],
      pipe[ ExtractItems[:kosapi_rooms, from: :exams, attr: :room], ConvertRooms, Sync[Room] ],
      Sync[Event, matching_attributes: [:faculty, :source_type, :source_id, :absolute_sequence_number]]
Severity: Major
Found in app/interactors/import_exams.rb and 1 other location - About 1 hr to fix
app/interactors/import_course_events.rb on lines 13..17

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

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

  def convert_exam(exam)
    ImportedExam.played_by(exam) do |exam|
      Event.new(
        starts_at: exam.start_date,
        ends_at: exam.end_date,
Severity: Minor
Found in app/interactors/convert_exams.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 plan_events has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def plan_events(slot, teacher)
    periods_query = @semester.semester_periods_dataset
      .where(type: ['teaching', 'exams'])
      .order(:starts_at)
    periods = periods_query.map { |p| PlannedSemesterPeriod.new(p) }
Severity: Minor
Found in lib/actors/teacher_timetable_slot_transformer.rb - About 1 hr to fix

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

        def then *guards, &block
          if guards.empty?
            return self if not self
          else
            guards.each do |cond|
    Severity: Minor
    Found in lib/core_ext/then.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 week_parity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def week_parity(date)
        return unless teaching?
    
        if date < starts_at.start_of_week || date > ends_at.end_of_week then
          fail ArgumentError, "The date's week is not within this period"
    Severity: Minor
    Found in app/models/semester_period.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def perform(events: , params: {}, format: :jsonapi)
            @format = format
    
            # XXX: This is a hack for backward compatibility. Parameter "deleted"
            # used to be a Boolean and we added additional value "all".
    Severity: Minor
    Found in app/interactors/api/filter_events.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 create_enum_setter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def create_enum_setter(column, column_schema)
              enum_values = column_schema[:enum_values].to_set
              if column_schema[:allow_null]
                enum_values.add(nil)
              end
    Severity: Minor
    Found in lib/sequel/plugins/enum_guard.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 validate_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_token(token)
            if token.status == 400
              "Invalid access token."
            elsif token.status != 200
              "Unable to verify access token (status: #{token.status}).".tap do |msg|
    Severity: Minor
    Found in lib/sirius_api/strategies/remote_oauth_server.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 has_any_role? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def has_any_role?(*roles)
          fail 'Cannot check roles without username.' unless username
    
          roles = Set.new(roles)
    
    
    Severity: Minor
    Found in lib/sirius_api/user.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

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

        weeks.split(',').flat_map { |interval|
          if interval.include?('-')
            from, to = interval.split('-', 2)
            (Integer(from)..Integer(to)).to_a
          else
    Severity: Minor
    Found in app/interactors/convert_tts.rb and 1 other location - About 25 mins to fix
    lib/actors/teacher_timetable_slot_transformer.rb on lines 83..88

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

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

      def convert_slot(slot, parallel_id)
        room_code = slot.room.link_id if slot.room
        slot_hash = slot.to_hash.select { |key, _| DB_KEYS.include? key }
        weeks = parse_weeks(slot.weeks)
    
    
    Severity: Minor
    Found in app/interactors/convert_tts.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

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

        def user_has_roles?(username, roles, operator: :all)
          fail ArgumentError, "Parameter 'username' must not be blank." if username.blank?
          fail ArgumentError, "Parameter 'roles' must not be empty." if roles.nil? || roles.empty?
    
          unless operator.to_s.in? %(all any none)
    Severity: Minor
    Found in lib/sirius_api/umapi_client.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

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

        weeks.split(',').flat_map { |interval|
          if interval.include?('-')
            from, to = interval.split('-', 2)
            (Integer(from)..Integer(to)).to_a
          else
    Severity: Minor
    Found in lib/actors/teacher_timetable_slot_transformer.rb and 1 other location - About 25 mins to fix
    app/interactors/convert_tts.rb on lines 56..61

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

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

      def receive_hungry
        return if output_hungry?
        if buffer_empty?
          @_output_state = :hungry
        else
    Severity: Minor
    Found in lib/actors/etl_producer.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 2 locations. Consider refactoring.
    Open

      class << self
        attr_accessor :resource, :source_key, :event_types
    
        def [](resource, source_key:, event_types:)
          Class.new(self).tap do |cls|
    Severity: Minor
    Found in app/interactors/fetch_students.rb and 1 other location - About 15 mins to fix
    app/interactors/extract_items.rb on lines 17..24

    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

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

      class << self
        attr_accessor :collection, :attribute, :result_key
    
        def [](result_key, from:, attr:)
          Class.new(self).tap do |cls|
    Severity: Minor
    Found in app/interactors/extract_items.rb and 1 other location - About 15 mins to fix
    app/interactors/fetch_students.rb on lines 43..50

    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

    Severity
    Category
    Status
    Source
    Language