openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method days has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def days
      month = @solution[0]
      weeks_days = @conf[:weeks_days]
      weeks_days = (0..6).to_a if weeks_days.blank?
      weeks_month = @conf[:weeks_month]
Severity: Minor
Found in app/models/setup/scheduler.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 post_digest_pull has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def post_digest_pull(request, _options = {})
        options = JSON.parse(request.body.read)
        message[:install] = options['install'].to_b if ask_for_install?
        unless (pull_parameters = options['pull_parameters']).is_a?(Hash)
          pull_parameters = {}
Severity: Minor
Found in app/controllers/api/v3/api_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 validate_file_stuff has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_file_stuff(options = {})
        if stash_data.nil?
          errors.add(:data, "can't be nil") if new_record?
        else
          self[:metadata] =
Severity: Minor
Found in lib/mongoff/grid_fs/file_stuff.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

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

        if (token = data[:token] || params[:token])
          if (captcha_token = CaptchaToken.where(token: token).first)
            if (code = data[:code] || params[:code])
              if code == captcha_token.code
                token_data = captcha_token.data || {}
Severity: Major
Found in app/controllers/api/v3/api_controller.rb and 1 other location - About 2 hrs to fix
app/controllers/api/v2/api_controller.rb on lines 288..308

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

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

      def read(file, *args)
        len = (args.length.positive? && args[0].to_i) || file.length || 0
        if (stash_data = file.stash_data)
          if stash_data.is_a?(String)
            cursor = file.cursor
Severity: Minor
Found in lib/cenit/file_store/base.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

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

        if (token = data[:token] || params[:token])
          if (captcha_token = CaptchaToken.where(token: token).first)
            if (code = data[:code] || params[:code])
              if code == captcha_token.code
                token_data = captcha_token.data || {}
Severity: Major
Found in app/controllers/api/v2/api_controller.rb and 1 other location - About 2 hrs to fix
app/controllers/api/v3/api_controller.rb on lines 183..203

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

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 hash_decode has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def hash_decode(value)
        case value
        when Hash
          r = nil
          if value.size == 1
Severity: Major
Found in lib/cenit/xmlrpc.rb - About 2 hrs to fix

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

      UpdaterTransformation.class_eval do
    
        def post_digest(request, _options = {})
          options = JSON.parse(request.body.read)
          execution = Setup::Translation.process(
    Severity: Major
    Found in app/controllers/api/v3/api_controller.rb and 2 other locations - About 2 hrs to fix
    app/controllers/api/v3/api_controller.rb on lines 1192..1219
    app/controllers/api/v3/api_controller.rb on lines 1292..1319

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

    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

      ConverterTransformation.class_eval do
    
        def post_digest(request, _options = {})
          options = JSON.parse(request.body.read)
          execution = Setup::Translation.process(
    Severity: Major
    Found in app/controllers/api/v3/api_controller.rb and 2 other locations - About 2 hrs to fix
    app/controllers/api/v3/api_controller.rb on lines 1192..1219
    app/controllers/api/v3/api_controller.rb on lines 1261..1288

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

    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

      Template.class_eval do
    
        def post_digest(request, _options = {})
          options = JSON.parse(request.body.read)
          execution = Setup::Translation.process(
    Severity: Major
    Found in app/controllers/api/v3/api_controller.rb and 2 other locations - About 2 hrs to fix
    app/controllers/api/v3/api_controller.rb on lines 1261..1288
    app/controllers/api/v3/api_controller.rb on lines 1292..1319

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

    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 run has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def run(message)
          if (hook = Cenit::Hook.where(id: message[:hook_id]).first)
            slug = message[:slug]
            if (hook_channel = hook.channels.where(slug: slug).first)
              if (data_type = hook_channel.data_type)
    Severity: Minor
    Found in app/models/setup/hook_data_processing.rb - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

            return false if (other_scope.auth? && !auth?) ||
              (other_scope.session_access? && !session_access?) ||
              (other_scope.offline_access? && !offline_access?) ||
              (other_scope.multi_tenant? && !multi_tenant?) ||
              !other_scope.openid_set.subset?(openid_set) ||
      Severity: Critical
      Found in app/models/cenit/oauth_scope.rb - About 2 hrs to fix

        Method check_properties has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def check_properties(properties, instance, state, data_type, options)
              path = options[:path] || '#'
              unless (checked_properties = state[:checked_properties])
                checked_properties = state[:checked_properties] = Set.new
              end
        Severity: Minor
        Found in lib/mongoff/validator.rb - About 2 hrs to fix

          Method find_record has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def find_record(conditions, *scopes)
                  scopes.each do |original_scope|
                    scope = original_scope
                    match_conditions = {}
                    begin
          Severity: Minor
          Found in lib/cenit/utility.rb - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                  if (options[:inspecting].include?(:_type) ||
                    options[:including].include?(:_type) ||
                    (enclosed_model && !record.orm_model.eql?(enclosed_model)) ||
                    (options[:polymorphic] && record.orm_model.hereditary?)) && !json['_reference'] && !options[:ignore].include?(:_type) && (!options[:only] || options[:only].include?(:_type))
                    json['_type'] = model.to_s
            Severity: Critical
            Found in lib/edi/formater.rb - About 2 hrs to fix

              Method do_map has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def do_map(source)
                    plain_properties = []
                    map_model.properties_schemas.each do |property, schema|
                      plain_properties << property unless schema[MappingModel::SCHEMA_FLAG]
                    end
              Severity: Minor
              Found in app/models/setup/mapping_converter.rb - About 1 hr to fix

                Method do_map has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def do_map(source)
                      plain_properties = []
                      map_model.properties_schemas.each do |property, schema|
                        plain_properties << property unless schema[MappingModel::SCHEMA_FLAG]
                      end
                Severity: Minor
                Found in app/models/setup/converter.rb - About 1 hr to fix

                  Method check_items has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def check_items(items_schema, items, state, data_type, options)
                        path = options[:path] || '#'
                        if items.is_a?(Mongoff::RecordArray)
                          items_schema = items.orm_model.schema
                          data_type = items.orm_model.data_type
                  Severity: Minor
                  Found in lib/mongoff/validator.rb - About 1 hr to fix

                    Method lookup_messages has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def lookup_messages(opts = {})
                            channel_mutex.lock
                            if channel && !channel.closed?
                              dispatched_ids = []
                              tenant_tasks = {}
                    Severity: Minor
                    Found in lib/cenit/rabbit.rb - About 1 hr to fix

                      Method validate_model has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def validate_model
                            if schema_code.is_a?(Hash)
                              if schema_changed?
                                begin
                                  json_schema, _ = validate_schema
                      Severity: Minor
                      Found in app/models/setup/json_data_type.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

                      Severity
                      Category
                      Status
                      Source
                      Language