osunyorg/admin

View on GitHub

Showing 27 of 43 total issues

Function setConfigs has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    setConfigs: function () {
        'use strict';
        this.setConfig('nothing',
            {
                toolbar: []
Severity: Major
Found in app/assets/javascripts/application/plugins/summernote.js - About 2 hrs to fix

    Function initSortable has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        initSortable: function () {
            'use strict';
            var nestedSortables,
                i;
    
    
    Severity: Minor
    Found in app/assets/javascripts/admin/plugins/treeview.js - About 1 hr to fix

      Method build_person has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def build_person
            if @email.present?
              person = find_person_with_email
            elsif @first_name.present? && @last_name.present?
              person = find_person_with_name_in_current_language
      Severity: Minor
      Found in app/services/importers/hash_to_person.rb - About 1 hr to fix

        Method organization has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def organization
              unless @organization
                if @siren.present? && @nic.present?
                  @organization = find_organization_with_siren_and_nic
                elsif @siren.present?
        Severity: Minor
        Found in app/services/importers/hash_to_organization.rb - About 1 hr to fix

          Method render_select_filter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def render_select_filter(f, name, value, options)
              options[:multiple] ||= false
              options[:collection] = options[:collection].map { |elmt| 
                if elmt.is_a?(String)
                  [elmt, elmt]
          Severity: Minor
          Found in app/helpers/admin/filters_helper.rb - About 1 hr to fix

            Method clean_html has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def self.clean_html(html)
                  # invalid byte sequence in UTF-8
                  # https://stackoverflow.com/questions/32826781/invalid-byte-sequence-in-utf-8-when-sanitizing-wordpress-export-content
                  html = html.force_encoding('UTF-8').scrub
                  # Relaxed config : https://github.com/rgrove/sanitize/blob/main/lib/sanitize/config/relaxed.rb
            Severity: Minor
            Found in app/services/importers/cleaner.rb - About 1 hr to fix

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

                  def self.send_confirmation_instructions(attributes = {})
                    confirmable = find_by_unconfirmed_email_with_errors(attributes) if reconfirmable
                    unless confirmable.try(:persisted?)
                      confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
                    end
              Severity: Minor
              Found in app/models/user/with_authentication.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

              Function sanitizeElementAttributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  sanitizeElementAttributes: function (elmt, allowedAttributes) {
                      'use strict';
                      var children = elmt.children,
                          child,
                          i,
              Severity: Minor
              Found in app/assets/javascripts/application/plugins/summernote.js - 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 organization has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def organization
                    unless @organization
                      if @siren.present? && @nic.present?
                        @organization = find_organization_with_siren_and_nic
                      elsif @siren.present?
              Severity: Minor
              Found in app/services/importers/hash_to_organization.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 file_validation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def file_validation
                  if file.attached?
                    unless file.blob.content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
                      file.purge if persisted?
                      errors.add(:file, :incorrect_type)
              Severity: Minor
              Found in app/models/import.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 hugo_ancestors_for_special_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def hugo_ancestors_for_special_page(website)
                  return [] if is_a?(Communication::Website::Page::Localization)
                  permalink = Communication::Website::Permalink.for_object(self, website)
                  return [] unless permalink
                  special_page = permalink.special_page(website)
              Severity: Minor
              Found in app/models/concerns/staticable.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 recursive_dependencies_add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def recursive_dependencies_add(array, dependency, syncable_only, follow_direct)
                  # Si l'objet ne doit pas être ajouté on n'ajoute pas non plus ses dépendances récursives
                  # C'est le fait de couper ici qui évite la boucle infinie
                  return array unless dependency_should_be_added?(array, dependency, syncable_only)
                  array << dependency if dependency.is_a?(ActiveRecord::Base)
              Severity: Minor
              Found in app/models/concerns/with_dependencies.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 extranet_access has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def extranet_access
                    unless user_can_access_registration_context?
                      extranet_l10n = registration_context.original_localization
                      if extranet_l10n.registration_contact.present?
                        errors.add :email, I18n.t('extranet.errors.email_not_allowed_with_contact', contact: extranet_l10n.registration_contact)
              Severity: Minor
              Found in app/models/user/with_registration_context.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 clean_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.clean_path(path)
                  clean_path = path.dup
                  # Remove eventual host
                  clean_path = URI(clean_path).path
                  # Leading slash for absolute path
              Severity: Minor
              Found in app/models/communication/website/permalink.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 osuny_collection_recursive has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def osuny_collection_recursive(list, level, localized, label_method)
                  collection = []
                  list.ordered(current_language).each do |object|
                    object_for_name = localized ? object.best_localization_for(current_language) : object
                    name = label_method.respond_to?(:call) ? label_method.call(object_for_name)
              Severity: Minor
              Found in app/helpers/admin/osuny_helper.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 render_radio_buttons_filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def render_radio_buttons_filter(f, name, value, options)
                  options[:collection] = options[:collection].map { |elmt| elmt.is_a?(String) ? [elmt, elmt] : [elmt.is_a?(Hash) ? elmt[:to_s] : elmt.to_s, elmt[:id]] }
              
                  f.input name, 
                          as: :radio_buttons, 
              Severity: Minor
              Found in app/helpers/admin/filters_helper.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 render_check_boxes_filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def render_check_boxes_filter(f, name, value, options)
                  options[:collection] = options[:collection].map { |elmt| elmt.is_a?(String) ? [elmt, elmt] : [elmt.is_a?(Hash) ? elmt[:to_s] : elmt.to_s, elmt[:id]] }
                  
                  f.input name, 
                          as: :check_boxes, 
              Severity: Minor
              Found in app/helpers/admin/filters_helper.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 hugo_ancestors_for_special_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def hugo_ancestors_for_special_page(website)
                  return [] if is_a?(Communication::Website::Page::Localization)
                  permalink = Communication::Website::Permalink.for_object(self, website)
                  return [] unless permalink
                  special_page = permalink.special_page(website)
              Severity: Minor
              Found in app/models/research/publication.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 from_omniauth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.from_omniauth(context, attributes)
                    mapping = context.sso_mapping || []
                    university = context.is_a?(University) ? context : context.university
              
                    # first step: we find the email (we are supposed to have an email mapping)
              Severity: Minor
              Found in app/models/user/with_omniauth.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 unpublished_by_last_save? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def unpublished_by_last_save?
                  return unless respond_to?(:published)
                  return true if saved_change_to_published? && !published?
                  if respond_to?(:published_at)
                    return saved_change_to_published_at? && (published_at.nil? || published_at > Time.now)
              Severity: Minor
              Found in app/models/concerns/with_dependencies.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

              Severity
              Category
              Status
              Source
              Language