zhandao/zero-rails_openapi

View on GitHub

Showing 13 of 16 total issues

Method open_api_dry has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def open_api_dry
      route_base = try(:controller_path) || instance_variable_get('@route_base')
      ::OpenApi::Generator.get_actions_by_route_base(route_base)&.each do |action|
        api_dry action do
          header! 'Token', String, desc: 'user token'
Severity: Minor
Found in examples/auto_gen_doc.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 open_api_dry has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def open_api_dry
      route_base = try(:controller_path) || instance_variable_get('@route_base')
      ::OpenApi::Generator.get_actions_by_route_base(route_base)&.each do |action|
        api_dry action do
          header! 'Token', String, desc: 'user token'
Severity: Minor
Found in examples/auto_gen_doc.rb - About 1 hr to fix

    Method process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def process
            return example_value if example_value
            return unless examples_hash
    
            examples_hash.map do |(name, value)|
    Severity: Minor
    Found in lib/oas_objs/example_obj.rb - About 55 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

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

          def param component_key, param_type, name, type, required, schema = { }
    Severity: Minor
    Found in lib/open_api/dsl/components.rb - About 45 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(name, param_type, type, required, schema)
      Severity: Minor
      Found in lib/oas_objs/param_obj.rb - About 35 mins to fix

        Method param has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def param param_type, name, type, required, schema = { }
        Severity: Minor
        Found in lib/open_api/dsl/api.rb - About 35 mins to fix

          Method arrow_writing_support has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def arrow_writing_support
                  proc do |args, executor|
                    args = (args.size == 1 && args.first.is_a?(Hash)) ? args[0].to_a.flatten : args
          
                    if !executor.in?(%w[ _example _security_scheme _base_auth _bearer_auth ]) && args.last.is_a?(Hash)
          Severity: Minor
          Found in lib/open_api/dsl/helpers.rb - About 35 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

          Method length has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def length
                  return unless _length
                  self._length = str_range_to_a(_length) if _length.is_a?(Range)
          
                  if _length.is_a?(Array)
          Severity: Minor
          Found in lib/oas_objs/schema_obj.rb - About 35 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

          Method process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def process
                  return { } if media_type.nil?
                  schema_processed = schema.process
                  result = schema_processed.values.join.blank? ? { } : { schema: schema_processed }
                  result[:example] = example.process unless example.nil?
          Severity: Minor
          Found in lib/oas_objs/media_type_obj.rb - About 35 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

          Method load_schema has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Confirmed

                def load_schema(model) # TODO: test
                  return unless Config.model_base && model.try(:superclass) == Config.model_base
                  model.columns.map do |column|
                      type = column.sql_type_metadata.type.to_s.camelize
                      type = 'DateTime' if type == 'Datetime'
          Severity: Minor
          Found in lib/open_api/dsl/helpers.rb - About 35 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

          Method param has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def param param_type, name, type, required, schema = { }
                  return if dry_skip&.include?(name) || dry_only&.exclude?(name)
          
                  return unless schema = process_schema_input(type, schema, name)
                  param_obj = ParamObj.new(name, param_type, type, required, schema)
          Severity: Minor
          Found in lib/open_api/dsl/api.rb - About 25 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

          Method process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def process
                  self.processed = {
                      mode =>
                          schemas.map do |schema|
                            type = schema.is_a?(Hash) ? schema[:type] : schema
          Severity: Minor
          Found in lib/oas_objs/combined_schema.rb - About 25 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

          Method inherited has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def inherited(subclass)
                super
                subclass.class_eval do
                  break unless self.name[/sController|sDoc/]
                  route_base self.name.sub('Doc', '').downcase.gsub('::', '/') if self.name[/sDoc/]
          Severity: Minor
          Found in examples/auto_gen_doc.rb - About 25 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

          Severity
          Category
          Status
          Source
          Language