ddd-ruby/contracts.ruby

View on GitHub

Showing 5 of 23 total issues

File builtin_contracts.rb has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Contracts
  module Builtin
    # Check that an argument is +Numeric+.
    class Num
      def self.valid?(val)
Severity: Minor
Found in lib/contracts/builtin_contracts.rb - About 4 hrs to fix

    Class MethodHandler has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class MethodHandler
        METHOD_REFERENCE_FACTORY = {
          :class_methods    => SingletonMethodReference,
          :instance_methods => MethodReference
        }.freeze
    Severity: Minor
    Found in lib/contracts/method_handler.rb - About 2 hrs to fix

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

          def execute_on_target(obj, name, method_type, current_engine, *args, &blk)
      Severity: Minor
      Found in lib/contracts/method_handler.rb - About 45 mins to fix

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

            def fail_if_invalid(validator, arg, arg_pos, args_size, contract)
        Severity: Minor
        Found in lib/contracts/args_validator.rb - About 35 mins to fix

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

              def message
                s = []
                s << header.to_s
                s << "        Expected: #{expected}"
                s << "        Actual: #{data[:arg].inspect}"
          Severity: Minor
          Found in lib/contracts/error_formatter.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