openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Avoid deeply nested control flow statements.
Open

              if (obj = (obj.reload rescue nil))
Severity: Major
Found in lib/cenit/utility.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                      next unless kept
    Severity: Major
    Found in lib/edi/parser.rb - About 45 mins to fix

      Method do_store has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def do_store(json, key, value, options, schema = {}, store_anyway = false)
      Severity: Minor
      Found in lib/edi/formater.rb - About 45 mins to fix

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

          def to_time_span(metric = :s)
            v = self.abs.to_i
            str = ''
            h = {
              ms: 1000,
        Severity: Minor
        Found in lib/cenit/core_ext.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

        Avoid deeply nested control flow statements.
        Open

                        if (property_value = json[name])
                          association = record.send(property_name)
                          next unless updating || association.blank?
                          sub_values =
                            if updating_associations.include?(property_name)
        Severity: Major
        Found in lib/edi/parser.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            if (association_track = associations[property])
                              next unless associations[:kept]
                              sub_values = association_track[:new]
                            else
                              associations[property] = {
          Severity: Major
          Found in lib/edi/parser.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            next if updating && ((property_name == '_id' || primary_fields.include?(name.to_sym)) && !record.send(property_name).nil?)
            Severity: Major
            Found in lib/edi/parser.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if (token = message[:token])
                                TaskToken.where(token: token).delete_all
                              end
              Severity: Major
              Found in lib/cenit/rabbit.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                  if (sub_record = do_parse_xml(data_type, property_model, sub_element, options, property_schema, nil, nil, property))
                                    record.send("#{property}=", sub_record)
                                  end
                Severity: Major
                Found in lib/edi/parser.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                    members = [members] unless members.is_a?(Array)
                  Severity: Major
                  Found in lib/cenit/xmlrpc.rb - About 45 mins to fix

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

                        def file_stores(*args)
                          if args.length.zero?
                            options[:file_stores] || [options.key?(:default_file_store) ? default_file_store : Cenit::FileStore::LocalDb]
                          else
                            args = args.flatten
                    Severity: Minor
                    Found in lib/cenit/cenit.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

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

                                        if value.save(options)
                                          if new_record || value.instance_variable_get(:@dynamically_created)
                                            value.instance_variable_set(:@dynamically_created, true)
                                            options[:create_collector] << value if options[:create_collector]
                                          else
                    Severity: Minor
                    Found in lib/cenit/utility.rb and 1 other location - About 45 mins to fix
                    lib/cenit/utility.rb on lines 251..260

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

                    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

                                  if value.save(options)
                                    if new_record || value.instance_variable_get(:@dynamically_created)
                                      value.instance_variable_set(:@dynamically_created, true)
                                      options[:create_collector] << value if options[:create_collector]
                                    else
                    Severity: Minor
                    Found in lib/cenit/utility.rb and 1 other location - About 45 mins to fix
                    lib/cenit/utility.rb on lines 280..289

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

                    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

                    Consider simplifying this complex logical expression.
                    Open

                          if !(value = super).nil? &&
                             (new_record? || !self.class.build_in_data_type.protecting?(name) ||
                               (current_user = User.current) &&
                                 (current_user.account_ids.include?(tenant_id) ||
                                   current_user.super_admin?))
                    Severity: Major
                    Found in app/models/concerns/setup/cross_origin_shared.rb - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                            if (match = /\Adata_(.+)\Z/.match(symbol.to_s)) &&
                               COLLECTING_PROPERTIES.include?(relation_name = match[1].to_sym) &&
                               ((args.length.zero? && (options = {})) || args.length == 1 && (options = args[0]).is_a?(Hash))
                              if (items = send(relation_name)).present?
                                items
                      Severity: Major
                      Found in app/models/setup/cross_shared_collection.rb - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                    if source_association && source_association.many? &&
                                      (target_association.nil? || !target_association.many?) && # target_association is nil for file mappings
                                      !transformation.bulk_source
                                      sub_map.errors.add(:source, "is a many association and can not be mapped to #{target_data_type.custom_title} | #{schema['title'] || name.to_title} (which is not many) with the non bulk transformation #{transformation.custom_title}")
                                    end
                        Severity: Major
                        Found in app/models/setup/converter.rb - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                              elsif (action == :simple_cross && crossing_models.exclude?(subject.is_a?(Class) ? subject : subject.class)) ||
                                (subject == ScriptExecution && (user.nil? || !user.super_admin?))
                                false
                              else
                                super || deferred_abilities.any? { |ability| ability.can?(action, subject, *extra_args) }
                          Severity: Major
                          Found in app/models/ability.rb - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                              if property_model && property_value.is_a?(Hash) && property_value['_reference'] && ((property_value[:id].nil? && property_value[:_id].nil?) || options[:skip_refs_binding])
                                                record.send("#{property_name}=", nil)
                                                property_value = Cenit::Utility.deep_remove(property_value, '_reference')
                                                unless (references = record.instance_variable_get(:@_references))
                                                  record.instance_variable_set(:@_references, references = {})
                            Severity: Major
                            Found in lib/edi/parser.rb - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                        if (sub_model = json['_type']) &&
                                          sub_model.is_a?(String) &&
                                          (sub_model = sub_model.start_with?('self[') ? (json.send(:eval, sub_model) rescue nil) : sub_model) &&
                                          (data_type = data_type.find_data_type(sub_model)) &&
                                          (sub_model = data_type.records_model) &&
                              Severity: Major
                              Found in lib/edi/parser.rb - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if (sub_model = json['_type']) &&
                                          sub_model.is_a?(String) &&
                                          (sub_model = sub_model.start_with?('self[') ? (json.send(:eval, sub_model) rescue nil) : sub_model) &&
                                          (data_type = data_type.find_data_type(sub_model)) &&
                                          (sub_model = data_type.records_model) &&
                                Severity: Major
                                Found in lib/edi/parser.rb - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language