openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

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

    def lazada_rest_api_refresh_token(authorization)
      if is_time_to_refresh?(authorization, Cenit.delay_time_for_lazada_token_refresh)
        client = authorization.client
        fail 'Missing client configuration' unless client
        fail 'Missing OAuth provider configuration' unless authorization.provider
Severity: Minor
Found in app/models/setup/base_oauth_provider.rb - About 1 hr to fix

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

        def post_digest_token(request, _options = {})
          error_field = '$'
          body = request.body.read
          payload =
            if body.blank?
    Severity: Minor
    Found in app/controllers/api/v3/api_controller.rb - About 1 hr to fix

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

          def post_digest(request, options = {})
            readable =
              if request.content_type.downcase == 'multipart/form-data'
                request.params[:data] || request.params[:file] || fail('Missing data (or file) part')
              else
      Severity: Minor
      Found in app/controllers/api/v3/api_controller.rb - About 1 hr to fix

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

            def template_options
              @template_options ||=
                begin
                  unless (opts = Cenit::Utility.json_value_of(request.headers['X-Template-Options'])).is_a?(Hash)
                    opts = {}
        Severity: Minor
        Found in app/controllers/api/v3/api_controller.rb - About 1 hr to fix

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

              def push
                response =
                  {
                    success: success_report = Hash.new { |h, k| h[k] = [] },
                    errors: broken_report = Hash.new { |h, k| h[k] = [] }
          Severity: Minor
          Found in app/controllers/api/v1/api_controller.rb - About 1 hr to fix

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

                def authorize_account
                  user = nil
            
                  # New key and token params.
                  key = request.headers['X-Tenant-Access-Key'] || params.delete('X-Tenant-Access-Key')
            Severity: Minor
            Found in app/controllers/api/v1/api_controller.rb - About 1 hr to fix

              Method native_hash_format has 30 lines of code (exceeds 25 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

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

                      def process_options(options)
                        p =
                          case (p = options.delete(:primary_fields) || options.delete('primary_fields'))
                          when Array
                            p
                Severity: Minor
                Found in lib/edi/parser.rb - About 1 hr to fix

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

                      def do_store(json, key, value, options, schema = {}, store_anyway = false)
                        if options[:nqnames]
                          key = key.to_s.split(':').last
                        end
                        if value.nil?
                  Severity: Minor
                  Found in lib/edi/formater.rb - About 1 hr to fix

                    Method config_pull_parameters has 29 lines of code (exceeds 25 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

                      Method update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def update
                            parser_options = self.parser_options.dup
                            parser_options[:add_only] = true
                            async = klass.is_a?(Class) && klass < Setup::AsynchronousPersistence::Model
                            if async
                      Severity: Minor
                      Found in app/controllers/api/v3/api_controller.rb - About 1 hr to fix

                        Method initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def initialize(model, array, referenced, parent)
                              @null = !array
                              array ||= []
                              @parent = parent
                              @model = model
                        Severity: Minor
                        Found in lib/mongoff/record_array.rb - About 1 hr to fix

                          Method to_json_schema has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def to_json_schema
                                json = documenting('type' => 'object', 'title' => tag_name.to_title)
                                json['properties'] = properties = {}
                                required = []
                                if max_occurs == :unbounded || max_occurs.positive? || min_occurs > 1
                          Severity: Minor
                          Found in lib/xsd/container.rb - About 1 hr to fix

                            Method property_model has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def property_model(property)
                                  property = property.to_s
                                  model = nil
                                  if schema.is_a?(Hash) && schema['type'] == 'object' && schema['properties'].is_a?(Hash) && (property_schema = schema['properties'][property])
                                    if properties_models.key?(property)
                            Severity: Minor
                            Found in lib/mongoff/model.rb - About 1 hr to fix

                              Method to_time_span has 29 lines of code (exceeds 25 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 1 hr to fix

                                Method prepare_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def prepare_options(options)
                                      include_id = options[:include_id]
                                      [:ignore, :only, :embedding, :inspecting, :including].each do |option|
                                        value = (options[option] || [])
                                        value = [value] unless value.is_a?(Enumerable)
                                Severity: Minor
                                Found in lib/edi/formater.rb - About 1 hr to fix

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

                                        def file_mapping_schema
                                          field_schema = { type: 'string' }
                                          if (source = auto_complete_source).present?
                                            field_schema['format'] = 'auto-complete'
                                            field_schema['source'] = source
                                  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 396..412

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

                                  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 file_mapping_schema
                                          field_schema = { type: 'string' }
                                          if (source = auto_complete_source).present?
                                            field_schema['format'] = 'auto-complete'
                                            field_schema['source'] = source
                                  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 398..414

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

                                  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 do_parse_json has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                        def do_parse_json(data_type, model, json, options, json_schema, record = nil, new_record = nil, container = nil, container_schema = nil)
                                  Severity: Major
                                  Found in lib/edi/parser.rb - About 1 hr to fix

                                    Method do_parse_edi has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                          def do_parse_edi(data_type, model, content, json_schema, start, field_sep, segment_sep, report, options = {})
                                    Severity: Major
                                    Found in lib/edi/parser.rb - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language