moviepilot/lacerda

View on GitHub

Showing 28 of 28 total issues

Method schema_contains? has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

      def schema_contains?(options)
        publish      = options[:publish]
        consume      = options[:consume]
        location     = options[:location] || []
        return false unless publish and consume
Severity: Minor
Found in lib/lacerda/compare/json_schema.rb - About 1 day 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_contains? has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def schema_contains?(options)
        publish      = options[:publish]
        consume      = options[:consume]
        location     = options[:location] || []
        return false unless publish and consume
Severity: Major
Found in lib/lacerda/compare/json_schema.rb - About 3 hrs to fix

    Method install_tasks has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def install_tasks
          namespace :lacerda do
            desc "Clean up intermediary json files"
            task :cleanup do
              path = File.expand_path("../contracts")
    Severity: Minor
    Found in lib/lacerda/tasks.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 contracts_fulfilled? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def contracts_fulfilled?(reporter = nil)
          reporter = Lacerda.validate_reporter(reporter)
    
          @mutex1.synchronize do
            @errors = {}
    Severity: Minor
    Found in lib/lacerda/infrastructure.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 install_tasks has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def install_tasks
          namespace :lacerda do
            desc "Clean up intermediary json files"
            task :cleanup do
              path = File.expand_path("../contracts")
    Severity: Minor
    Found in lib/lacerda/tasks.rb - About 1 hr to fix

      Method contracts_fulfilled? has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def contracts_fulfilled?(reporter = nil)
            reporter = Lacerda.validate_reporter(reporter)
      
            @mutex1.synchronize do
              @errors = {}
      Severity: Minor
      Found in lib/lacerda/infrastructure.rb - About 1 hr to fix

        Method mson_to_json_schema! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.mson_to_json_schema!(options)
              filename = options.fetch(:filename)
        
              # For now, we'll use the containing directory's name as a scope
              service_scope = File.dirname(filename).split(File::SEPARATOR).last.underscore
        Severity: Minor
        Found in lib/lacerda/conversion.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                        next unless schema_contains?(publish: publish, consume: consume_type, location: location)
          Severity: Major
          Found in lib/lacerda/compare/json_schema.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      elsif consume['properties'] and publish['oneOf']
                        publish_types = ([publish['oneOf']].flatten - [{"type" => "null"}]).sort
                        incompatible_publish_type= nil
                        original_errors = @errors
                        @errors = []
            Severity: Major
            Found in lib/lacerda/compare/json_schema.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if publish_types.size == 1 && consume_types.size == 1
                                @errors.push(*errors)
                              else
                                _e(:ERR_MISSING_MULTI_PUBLISH_MULTI_CONSUME, location, publish_type)
                              end
              Severity: Major
              Found in lib/lacerda/compare/json_schema.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            unless compatible_consume_type_found
                              return _e(:ERR_MISSING_SINGLE_PUBLISH_MULTI_CONSUME, location, publish['type'])
                            end
                Severity: Major
                Found in lib/lacerda/compare/json_schema.rb - About 45 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                          return _e(:ERR_MISSING_TYPE_AND_REF_AND_ONE_OF, location) unless
                            (consume['type'] or consume['$ref'] or consume['oneOf']) and
                            (publish['type'] or publish['$ref'] or publish['oneOf'])
                  Severity: Major
                  Found in lib/lacerda/compare/json_schema.rb - About 40 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return false
                    Severity: Major
                    Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                    return false unless schema_contains?(publish: publish['properties'][property], consume: schema, location: location + [property])
                      Severity: Major
                      Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                      return _e(:ERR_MISSING_MULTI_PUBLISH_SINGLE_CONSUME, location, incompatible_publish_type)
                        Severity: Major
                        Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return _e(:ERR_NOT_IMPLEMENTED, location, "'items' can only be hash (schema)")
                          Severity: Major
                          Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                     return schema_contains?(publish: resolved_publish, consume: resolved_consume, location: location)
                            Severity: Major
                            Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return _e(:ERR_ARRAY_ITEM_MISMATCH, location, nil)
                              Severity: Major
                              Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return schema_contains?(publish: resolved_ref, consume: consume, location: location)
                                Severity: Major
                                Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                           return _e(:ERR_MISSING_POINTER, location, publish['$ref']) unless resolved_publish
                                  Severity: Major
                                  Found in lib/lacerda/compare/json_schema.rb - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language