kix/apiranha

View on GitHub

Showing 19 of 19 total issues

Function createDefinitions has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

    public function createDefinitions($source)
    {
        if (!interface_exists($source)) {
            throw new InvalidArgumentException(sprintf(
                'Class or interface `%s` is specified as a resource definition source, but it doesn\'t exist',
Severity: Minor
Found in src/Definition/Driver/AnnotationDriver.php - About 7 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 createDefinitions has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createDefinitions($source)
    {
        if (!interface_exists($source)) {
            throw new InvalidArgumentException(sprintf(
                'Class or interface `%s` is specified as a resource definition source, but it doesn\'t exist',
Severity: Major
Found in src/Definition/Driver/AnnotationDriver.php - About 4 hrs to fix

    Function __call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __call($name, $arguments)
        {
            if (!array_key_exists($name, $this->resources)) {
                throw UndefinedResourceException::create($name, array_keys($this->resources));
            }
    Severity: Minor
    Found in src/Endpoint.php - 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

    Function forTypeMismatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function forTypeMismatch($expected, $actual)
        {
            $expectedClasses = [];
            $expectedTypes = [];
            
    Severity: Minor
    Found in src/Exception/InvalidParameterException.php - 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

    Function hydrateParameters has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function hydrateParameters($definitions, $arguments)
        {
            $i = 0;
            $parameters = [];
    
    
    Severity: Minor
    Found in src/Resource/ParameterHydrator.php - 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 process has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function process(ResponseInterface $response, ResourceDefinitionInterface $resource)
        {
            if (!$response instanceof ApiResponse) {
                throw new \InvalidArgumentException(sprintf(
                    'Expected an ApiResponse, got %s',
    Severity: Minor
    Found in src/Hydrator/ReflectionHydratorListener.php - About 1 hr to fix

      Method execute has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $driver = new AnnotationDriver();
              $definitions = $driver->createDefinitions(GithubApi::class);
              $adapter = new GuzzleHttpAdapter(new Client());
      Severity: Minor
      Found in examples/Command/ListReposCommand.php - About 1 hr to fix

        Method forTypeMismatch has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function forTypeMismatch($expected, $actual)
            {
                $expectedClasses = [];
                $expectedTypes = [];
                
        Severity: Minor
        Found in src/Exception/InvalidParameterException.php - About 1 hr to fix

          Method generate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function generate(ResourceDefinitionInterface $resourceDefinition, array $parameters = array())
              {
                  $definedParams = $resourceDefinition->getParameters();
          
                  if (count($definedParams) < count($parameters)) {
          Severity: Minor
          Found in src/Router.php - About 1 hr to fix

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

                public static function processParameters($path, array $parameters = array())
                {
                    preg_match_all('/\{([a-zA-Z.]+)\}/', $path, $matches);
                    $paramNames = $matches[1];
                    
            Severity: Minor
            Found in src/ResourceDefinition.php - About 1 hr to fix

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

                  public function __call($name, $arguments)
                  {
                      if (!array_key_exists($name, $this->resources)) {
                          throw UndefinedResourceException::create($name, array_keys($this->resources));
                      }
              Severity: Minor
              Found in src/Endpoint.php - About 1 hr to fix

                Method createEndpoint has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function createEndpoint($baseUrl, array $definitions, array $listeners = array(), HttpAdapterInterface $adapter = null, Router $router = null)
                    {
                        if (!$adapter) {
                            $adapter = new GuzzleHttpAdapter(new Client());
                        }
                Severity: Minor
                Found in src/Builder.php - About 1 hr to fix

                  Method process has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function process(ResponseInterface $response, ResourceDefinitionInterface $resource)
                      {
                          if (!$response instanceof ApiResponse) {
                              throw new InvalidArgumentException(sprintf(
                                  'Expected an `ApiResponse`, got `%s` instead',
                  Severity: Minor
                  Found in src/Hydrator/GeneratedHydratorListener.php - About 1 hr to fix

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

                        public static function createEndpoint($baseUrl, array $definitions, array $listeners = array(), HttpAdapterInterface $adapter = null, Router $router = null)
                    Severity: Minor
                    Found in src/Builder.php - About 35 mins to fix

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

                          public function __construct($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1')
                      Severity: Minor
                      Found in src/Request/Request.php - About 35 mins to fix

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

                            public function __construct($name, $method, $path, $returnType = null, array $parameters = array())
                        Severity: Minor
                        Found in src/ResourceDefinition.php - About 35 mins to fix

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

                              public function process(ResponseInterface $response, ResourceDefinitionInterface $resource)
                              {
                                  if (!$response instanceof ApiResponse) {
                                      throw new \InvalidArgumentException(sprintf(
                                          'Expected an ApiResponse, got %s',
                          Severity: Minor
                          Found in src/Hydrator/ReflectionHydratorListener.php - 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

                          Function createEndpoint has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function createEndpoint($baseUrl, array $definitions, array $listeners = array(), HttpAdapterInterface $adapter = null, Router $router = null)
                              {
                                  if (!$adapter) {
                                      $adapter = new GuzzleHttpAdapter(new Client());
                                  }
                          Severity: Minor
                          Found in src/Builder.php - 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

                          Function processParameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function processParameters($path, array $parameters = array())
                              {
                                  preg_match_all('/\{([a-zA-Z.]+)\}/', $path, $matches);
                                  $paramNames = $matches[1];
                                  
                          Severity: Minor
                          Found in src/ResourceDefinition.php - 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

                          Severity
                          Category
                          Status
                          Source
                          Language