zhandao/zero-rails

View on GitHub

Showing 7 of 11 total issues

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

    def open_api_dry
      route_base = try(:controller_path) || oas[:route_base]
      ::OpenApi::Router.get_actions_by_route_base(route_base)&.each do |action|
        api_dry action do
          # Common :index parameters
Severity: Minor
Found in lib/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 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def open_api_dry
      route_base = try(:controller_path) || oas[:route_base]
      ::OpenApi::Router.get_actions_by_route_base(route_base)&.each do |action|
        api_dry action do
          # Common :index parameters
Severity: Minor
Found in lib/auto_gen_doc.rb - About 1 hr to fix

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

        def register(name, path = nil, format: :normal)
          name = name.to_sym
          path = nil if Rails.env.test? && path&.match?('/data/logs') # for ci
          return puts "Logger named #{name} has exists".red if loggers&.key?(name.to_sym)
    
    
    Severity: Minor
    Found in lib/loggers.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 can? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def can? *permission_codes, source: nil, &block
        block_condition = permission_codes.delete(:then) || permission_codes.delete(:else)
        permission_codes.flatten.each do |code|
          vp = vactual_permissions = [ *Array(MakeSure.permission_mapper[code] || code) ]
          # vp = [ *vp, *PermissionCode.where(code: code).map(&:permissions).flatten.compact.map(&:name).uniq ]
    Severity: Minor
    Found in app/controllers/concerns/make_sure.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 must has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def must *logic_names
        success = nil
        logic_names.each do |logic_name|
          logic = MakeSure.logics.fetch(logic_name)
          result = logic[:lambda] ? @_make_sure_obj.instance_exec(&logic[:lambda]) : instance_eval(&logic[:block])
    Severity: Minor
    Found in app/controllers/concerns/make_sure.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 make_sure has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def make_sure(obj = NoPass, action = nil, *args, &block)
        @_make_sure_obj = obj if obj == :it
        @_make_sure_obj = current_user if obj == NoPass
        return self if action.nil?
    
    
    Severity: Minor
    Found in app/controllers/concerns/make_sure.rb - About 45 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 name.match?(/Controller|Doc/)
            route_base name.sub('Doc', '').underscore.gsub('::', '/') if name.match?(/Doc/)
    Severity: Minor
    Found in lib/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