openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method fresh_access_token has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def fresh_access_token
      if authorized_at.nil? || (authorized_at + (token_span || 0) < Time.now - 60)
        fail 'Invalid client' unless client.is_a?(Setup::Application)
        fail 'Invalid refresh token' unless (token = Cenit::OauthRefreshToken.where(token: refresh_token).first)
        fail 'Refresh token app mismatch' unless token.application_id == client.application_id
Severity: Minor
Found in app/models/setup/app_authorization.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 method_missing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(symbol, *args)
      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?
Severity: Minor
Found in app/models/setup/cross_shared_collection.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 intuit_reconnect_api_v1_refresh_token has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def intuit_reconnect_api_v1_refresh_token(authorization)
      return unless authorization.authorized_at + 151.days < Time.now
      url = 'https://appcenter.intuit.com/api/v1/connection/reconnect'
      response = Setup::Connection.get(url).with(authorization).submit(http_proxy_address: Cenit.http_proxy_address,
                                                                       http_proxy_port: Cenit.http_proxy_port)
Severity: Minor
Found in app/models/setup/base_oauth_provider.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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def run(message)
      origin = origin_from(message)
      criteria = objects_from(message)
      model = data_type.records_model
      if model < CrossOrigin::CenitDocument
Severity: Minor
Found in app/models/setup/crossing.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 config_pull_parameters has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def config_pull_parameters
      unless @config_pull_parameters
        @config_pull_parameters = []
        [Setup::RemoteOauthClient, Setup::GenericAuthorizationClient].each do |client_model|
          clients = COLLECTING_PROPERTIES.detect { |p| reflect_on_association(p).klass == client_model }.to_s
Severity: Minor
Found in app/models/setup/cross_shared_collection.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 mapping= has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def mapping=(data)
      return unless style == 'mapping'
      unless data.is_a?(Hash)
        data =
          if data.is_a?(String)
Severity: Minor
Found in app/models/setup/converter.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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def run(message)
      clear_hashes
      if pull_request_hash.present?
        pull_request_hash[:install] = message[:install].to_b if ask_for_install?
        if (pull_parameters = message[:pull_parameters]).is_a?(Hash)
Severity: Minor
Found in app/models/setup/base_pull.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 schema has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def schema
      # TODO: Factorize code with algorithms and applications parameters
      sch =
        if type.blank?
          {}
Severity: Minor
Found in app/models/setup/cross_collection_pull_parameter.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 notification_span_for has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def notification_span_for(type)
    type = type.to_s.to_sym
    unless @notification_spans
      @notification_spans = {}
      regex = Regexp.new("\\A(#{Setup::SystemNotification.type_enum.join('|')})_notifications_span\\Z")
Severity: Minor
Found in app/models/user.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_referenced_schema has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def check_referenced_schema(schema, check_for_array = true)
      if schema.is_a?(Hash) && (schema = schema.reject { |key, _| %w(types contextual_params data filter group xml unique title description edi format example enum readOnly default visible referenced_by maxProperties minProperties auto export_embedded exclusive).include?(key) })
        property_dt = nil
        ns = data_type.namespace
        if (ref = schema['$ref']).is_a?(Array)
Severity: Minor
Found in lib/mongoff/model.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 native_hash_format has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def native_hash_format(options = {}, alg_delegator_method)
        if (alg_methods = orm_model.data_type.records_methods.select { |alg| %w(to_hash to_json).include?(alg.name) }).present?
          alg_delegator_method =
            if alg_methods.length == 1 || alg_methods[0].name == alg_delegator_method.to_s
              alg_methods[0].name
Severity: Minor
Found in lib/mongoff/grid_fs/file_formatter.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 insert_or_update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def insert_or_update(options = {})
      if new_record?
        r = orm_model.collection.insert_one(attributes)
        unless id == r.inserted_ids[0]
          self.id = r.inserted_ids[0]
Severity: Minor
Found in lib/mongoff/savable.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 find_app has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def find_app
    found = false
    if (@id_routing && (app = @app)) ||
       ((ns = Setup::Namespace.where(slug: params[:id_or_ns]).first) &&
         (app = Setup::Application.where(namespace: ns.name, slug: params[:app_slug]).first))
Severity: Minor
Found in app/controllers/app_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 each_deep_pair has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def each_deep_pair(&block)
    each_pair do |key, value|
      if yield(self, key, value)
        case value
          when Hash
Severity: Minor
Found in lib/cenit/core_ext.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 detask has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def detask(message)
        report = nil
        case task = message.delete(:task)
        when Class
          task_class = task
Severity: Minor
Found in lib/cenit/rabbit.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 build_in_provider_id has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def build_in_provider_id
        unless @build_in_provider_id
          basic_attrs = {
            namespace: 'Cenit',
            name: 'OAuth',
Severity: Minor
Found in app/models/setup/oauth2_provider.rb - About 1 hr to fix

    Method simple_translate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def simple_translate(message, &block)
          unless (options = message[:options]).is_a?(Hash)
            options = {}
          end
          task = message[:task]
    Severity: Minor
    Found in app/models/setup/flow.rb - About 1 hr to fix

      Method translate_import has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def translate_import(message, &block)
            options =
              {
                headers: message['headers'] || {},
                parameters: message['parameters'] || {},
      Severity: Minor
      Found in app/models/setup/flow.rb - About 1 hr to fix

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

                elsif data[:email]
                  data[:password] = Devise.friendly_token unless data[:password]
                  data[:password_confirmation] = data[:password] unless data[:password_confirmation]
                  if (user = User.new(data)).valid?(context: :create)
                    if (captcha_token = CaptchaToken.create(email: data[:email], data: data)).errors.blank?
        Severity: Major
        Found in app/controllers/api/v1/api_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/api/v2/api_controller.rb on lines 310..325

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

        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

                elsif data[:email]
                  data[:password] = Devise.friendly_token unless data[:password]
                  data[:password_confirmation] = data[:password] unless data[:password_confirmation]
                  if (user = User.new(data)).valid?(context: :create)
                    if (captcha_token = CaptchaToken.create(email: data[:email], data: data)).errors.blank?
        Severity: Major
        Found in app/controllers/api/v2/api_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/api/v1/api_controller.rb on lines 205..220

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

        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

        Severity
        Category
        Status
        Source
        Language