openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(symbol, *args, &block)
      if METHODS.include?(symbol)
        options =
          if args.length == 1 && block
            base_method_name =
Severity: Minor
Found in app/controllers/build_in_app_base_controller.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 handle_get_digest has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_get_digest(controller)
      if (id = controller.request.headers['X-Record-Id'])
        controller.setup_request(namespace: ns_slug, klass: records_model, id: id)
        controller.show if (item = controller.find_item) && controller.authorize_action(
          action: :read,
Severity: Minor
Found in app/controllers/api/v3/api_controller.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 access_less_scope has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def access_less_scope
      ((auth? ? "#{AUTH_TOKEN} " : '') +
        (session_access? ? "#{SESSION_ACCESS_TOKEN} " : '') +
        (offline_access? ? "#{OFFLINE_ACCESS_TOKEN} " : '') +
        (multi_tenant? ? "#{MULTI_TENANT_TOKEN} " : '') +
Severity: Minor
Found in app/models/cenit/oauth_scope.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 post_digest_access has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def post_digest_access(request, options = {})
      scope = ::Cenit::OauthScope.new(JSON.parse(request.body.read)['scope'])
      fail 'Is not valid' unless scope.valid?
      access_grant = ::Cenit::OauthAccessGrant.where(
        application_id_id: application_id_id
Severity: Minor
Found in app/controllers/api/v3/api_controller.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 check_oneOf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def check_oneOf(schemas, instance, _, data_type)
      one_index = nil
      schemas.each_with_index do |schema, index|
        valid =
          begin
Severity: Minor
Found in lib/mongoff/validator.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 initialize_bounds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize_bounds(args)
      max_occurs = attributeValue(:maxOccurs, args[:attributes])
      @max_occurs =
        if max_occurs
          max_occurs == 'unbounded' ? :unbounded : max_occurs.to_i
Severity: Minor
Found in lib/xsd/bounded_tag.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 process_element_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def process_element_message(primary_method, alternative_method, name, attributes = nil)
      if top.respond_to?(primary_method)
        return top.send(primary_method, attributes) if attributes
        return top.send(primary_method)
      elsif top_available? && top.respond_to?(alternative_method)
Severity: Minor
Found in lib/xsd/document.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 check_schema_items has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def check_schema_items(items_schema)
      _check_type(:items, items_schema, Hash, Array)
      if items_schema.is_a?(Hash)
        begin
          validate(items_schema)
Severity: Minor
Found in lib/mongoff/validator.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 default_file_store has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def default_file_store(*args)
      if args.length.zero?
        options[:default_file_store] || file_stores.first
      else
        default_file_store =
Severity: Minor
Found in lib/cenit/cenit.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 save has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def save(file, data, options)
        file[:chunkSize] = [[file[:chunkSize] || 0, Mongoff::GridFs::FileModel::MINIMUM_CHUNK_SIZE].max, Mongoff::GridFs::FileModel::MAXIMUM_CHUNK_SIZE].min
        temporary_file = nil
        readable =
            if data.is_a?(String)
Severity: Minor
Found in lib/cenit/file_store/local_db.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 generate_access_token has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_access_token(options = {})
      unless (app_id = app.application_id)
        fail 'Invalid App, the app identifier ref is broken!'
      end
      unless (access_grant = Cenit::OauthAccessGrant.where(application_id_id: app_id.id).first)
Severity: Minor
Found in lib/cenit/control.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 run_code has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def run_code(*args)
        fail "Code expected as first argument but #{code.class} found" unless (code = args.shift).is_a?(String)
        if (locals = args.shift || {}).is_a?(Hash)
          locals = locals.symbolize_keys
        else
Severity: Minor
Found in lib/cenit/bundler_interpreter.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 save has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def save(file, data, options)
        file.instance_variable_set(:@_store_io, nil)
        opts = {
          content_type: file[:contentType],
          metadata: {
Severity: Minor
Found in lib/cenit/file_store/aws_s3_default.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

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

    def map_model
      if source_data_type && target_data_type
        if @mongoff_model && @mongoff_model.data_type != target_data_type
          @mongoff_model = nil
        end
Severity: Major
Found in app/models/setup/mapping_converter.rb and 1 other location - About 1 hr to fix
app/models/setup/converter.rb on lines 258..272

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

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

    def map_model
      if source_data_type && target_data_type
        if @mongoff_model && @mongoff_model.data_type != target_data_type
          @mongoff_model = nil
        end
Severity: Major
Found in app/models/setup/converter.rb and 1 other location - About 1 hr to fix
app/models/setup/mapping_converter.rb on lines 263..277

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

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

            unless property_dt == source_data_type
              enum << property
              title = property_dt.schema['title'] || property.to_title
              if titles.include?(title)
                title = "#{title} (#{property.to_title})"
Severity: Major
Found in app/models/setup/mapping_converter.rb and 1 other location - About 1 hr to fix
app/models/setup/converter.rb on lines 381..389

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

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

            unless property_dt == source_data_type
              enum << property
              title = property_dt.schema['title'] || property.to_title
              if titles.include?(title)
                title = "#{title} (#{property.to_title})"
Severity: Major
Found in app/models/setup/converter.rb and 1 other location - About 1 hr to fix
app/models/setup/mapping_converter.rb on lines 383..391

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

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

    def optimize
      data_types = @nss.values.collect { |ns_hash| ns_hash.values.to_a }.flatten
      while (data_type = data_types.shift)
        segments = {}
        refs = Set.new
Severity: Minor
Found in app/models/setup/optimizer.rb - About 1 hr to fix

    Method validates_pull_parameters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def validates_pull_parameters
          with_errors = false
          data =
            if installed
              if new_record?
    Severity: Minor
    Found in app/models/setup/cross_shared_collection.rb - About 1 hr to fix

      Method parse_connections has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def parse_connections(namespace, collection)
            spec = self.spec_doc
            auth = collection[:authorizations].first
      
            collection[:connections] << conn = {
      Severity: Minor
      Found in app/models/setup/api_spec.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language