gems-uff/sapos

View on GitHub

Showing 283 of 383 total issues

Method send_emails has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def self.send_emails(notifications)
    Notifier.logger.info "Starting send_emails function."
    unless Notifier.should_run?
      Notifier.logger.info "Execution method is not 'Server'. Stoping process."
      return
Severity: Minor
Found in lib/notifier.rb - About 2 hrs 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 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def find
    source = admission_application_params[:_source]
    if Rails.application.config.should_use_recaptcha && !verify_recaptcha()
      raise FindException.new I18n.t("errors.admissions.invalid_captcha")
    end
Severity: Minor
Found in app/controllers/admissions/admissions_controller.rb - About 2 hrs 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 justification_grade_not_count_in_gpr_table has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def justification_grade_not_count_in_gpr_table(curr_pdf, options = {})
    enrollment ||= options[:enrollment]

    class_enrollments_which_grade_not_count_in_gpr = enrollment
      .class_enrollments.where(class_enrollments: { grade_not_count_in_gpr: 1 })
Severity: Major
Found in app/helpers/enrollments_pdf_helper.rb - About 2 hrs to fix

    Method set_default_values has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_default_values
        return if self.form_field.nil?
        configuration = self.form_field.config_hash
        case self.form_field.field_type
        when Admissions::FormField::STRING
    Severity: Minor
    Found in app/models/admissions/filled_form_field.rb - About 2 hrs 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 admission_applications_complete_table has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def admission_applications_complete_table(curr_pdf, options = {})
        admission_process ||= options[:admission_process]
        admission_report_config = @admission_report_config || Admissions::AdmissionReportConfig.new.init_default
        title = admission_process_pdf_title(admission_process)
        config = admission_report_config.prepare_table(admission_process)
    Severity: Minor
    Found in app/helpers/admissions/admission_processes_pdf_helper.rb - About 2 hrs 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

    Function config_form_field_scholarity has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function config_form_field_scholarity(form_field) {
      let r = (Math.random() + 1).toString(36).substring(7);
      //let title = form_field.i18n(field);
      let fields = [
        "level", "status", "institution", "course", "location", "grade",
    Severity: Major
    Found in app/assets/javascripts/form_fields/config_scholarity_fields.js - About 2 hrs to fix

      Method signature_footer has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def signature_footer(pdf, options = {})
          x = 5
      
          diff_width = options[:diff_width]
          diff_width ||= 0
      Severity: Major
      Found in app/helpers/pdf_helper.rb - About 2 hrs to fix

        Method update has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def update(creating: false)
            prepare_edit_update_application(creating: creating)
            was_filled = @admission_application.filled_form.is_filled
            @admission_application.assign_form(
              admission_application_params,
        Severity: Major
        Found in app/controllers/admissions/apply_controller.rb - About 2 hrs to fix

          Function config_form_field_select has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function config_form_field_select(form_field, field, selectable, options) {
            let r = (Math.random() + 1).toString(36).substring(7);
            let title = form_field.i18n(field);
            let id = `${form_field.baseid}_${field}_${r}`
            let value = form_field.data[field] || "";
          Severity: Major
          Found in app/assets/javascripts/form_fields/config_select.js - About 2 hrs to fix

            Method new_document has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def new_document(name, title, options = {}, &block)
                type = options[:pdf_type] || :report
                pdf_type = :"use_at_#{type}"
                pdf_config = (
                  options[:pdf_config] ||
            Severity: Major
            Found in app/helpers/pdf_helper.rb - About 2 hrs to fix

              Class ClassEnrollmentRequestsController has 24 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class ClassEnrollmentRequestsController < ApplicationController
                include EnrollmentSearchConcern
                include EnrollmentRequestSearchConcern
                authorize_resource
              
              
              Severity: Minor
              Found in app/controllers/class_enrollment_requests_controller.rb - About 2 hrs to fix

                Method assign_course_class_ids has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  def assign_course_class_ids(course_classes, class_schedule = nil)
                    # course classes is a list of strings representing course_class ids
                    request_change = {
                      new_removal_requests: [],
                      new_insertion_requests: [],
                Severity: Minor
                Found in app/models/enrollment_request.rb - About 2 hrs 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

                Function tokenBase has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function tokenBase(stream, state) {
                    var ch = stream.next();
                
                    // call hooks from the mime type
                    if (hooks[ch]) {
                Severity: Major
                Found in app/assets/javascripts/codemirror.sql.custom.js - About 2 hrs to fix

                  Function goToPx has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      t.goToPx = function(finalLeft, isAnimated, isLabelsDrawn) {
                          /*
                            finalLeft is negative
                  
                            I tried several implementations here, including:
                  Severity: Major
                  Found in app/assets/javascripts/chronoline/chronoline.js - About 2 hrs to fix

                    Method initialize_admissions has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def initialize_admissions(user, roles)
                        alias_action :map_student_form, :map_student_form_create_update, to: :map_student
                        alias_action :custom_report_generate, :reset_report, to: :custom_report
                        if roles[:manager]
                          can :undo_consolidation, Admissions::AdmissionApplication
                    Severity: Major
                    Found in app/models/admissions/ability.rb - About 2 hrs to fix

                      Method create_bigint_migration has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def create_bigint_migration
                          models = {}
                      
                          Dir["app/models/*"].each do |name|
                            model_name = name.match(/app\/models\/(.*?)\.rb/)[1].pluralize
                      Severity: Major
                      Found in lib/generators/migrate_bigint_generator.rb - About 2 hrs to fix

                        Class FilledFormField has 23 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class Admissions::FilledFormField < ActiveRecord::Base
                          has_paper_trail
                        
                          serialize :list
                        
                        
                        Severity: Minor
                        Found in app/models/admissions/filled_form_field.rb - About 2 hrs to fix

                          Method to_text has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def to_text(blank: "-", field_type: nil, custom: {})
                              return blank if self.form_field.blank?
                              form_field = self.form_field
                              field_type ||= form_field.field_type
                              if custom[field_type].present?
                          Severity: Major
                          Found in app/models/admissions/filled_form_field.rb - About 2 hrs to fix

                            Method student_has_other_scholarship_duration has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def student_has_other_scholarship_duration
                                return false if enrollment.nil?
                                return false if scholarship.nil?
                                # Se a bolsa é mais antiga que a atual    scholarship.start_date < start_date
                                # -> scholarship.cancel_date não é nulo -> scholarhsip.cancel < start_date
                            Severity: Minor
                            Found in app/models/scholarship_duration.rb - About 2 hrs 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 number_with_delimiter has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def number_with_delimiter(number, options = {})
                                options.symbolize_keys!
                            
                                if options[:format_as]
                                  return nil if number.nil?
                            Severity: Minor
                            Found in app/helpers/numbers_helper.rb - About 2 hrs 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

                            Severity
                            Category
                            Status
                            Source
                            Language