Showing 59 of 59 total issues
Function resolveParameters
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
protected function resolveParameters(array $refParameters, array $arguments): array
{
$parameters = [];
$nullable = 0;
- Read upRead up
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function piped(string ...$to): self
{
if ($this->asRoute) {
foreach ($to as $middleware) {
$this->routes[$this->defaultIndex]['middlewares'][$middleware] = true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 184.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function scheme(string ...$schemes): self
{
if ($this->asRoute) {
foreach ($schemes as $scheme) {
$this->routes[$this->defaultIndex]['schemes'][$scheme] = true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 184.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File PrototypeTrait.php
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
/*
* This file is part of Flight Routing.
*
Function load
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function load(array $annotations): RouteCollection
{
foreach ($annotations as $annotation) {
$reflection = $annotation['type'];
$attributes = $annotation['attributes'] ?? [];
- Read upRead up
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 buildCache
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function buildCache(RouteCollection $collection, bool $doCache): string
{
$dynamicRoutes = $dynamicVar = $staticRoutes = [];
$dynamicString = ":static function (string \$path): ?array {\n ";
- Read upRead up
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 addRoute
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function addRoute(RouteCollection $collection, Route $route, mixed $handler): RouteCollection
{
if (true !== $handler) {
if (empty($route->path)) {
throw new InvalidAnnotationException('Attributed method route path empty');
- Read upRead up
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
RouteCollection
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class RouteCollection implements \Countable, \ArrayAccess
{
use Traits\PrototypeTrait;
/**
Function interpolate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private static function interpolate(string $uriRoute, array $uriVars, array $parameters): string
{
$required = []; // Parameters required which are missing.
$replaces = self::URI_FIXERS;
- Read upRead up
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 resolveParameters
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function resolveParameters(array $refParameters, array $arguments): array
{
$parameters = [];
$nullable = 0;
Function __invoke
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function __invoke(mixed $handler, array $arguments): mixed
{
if (\is_string($handler)) {
$handler = \ltrim($handler, '\\');
- Read upRead up
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 domain
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function domain(string ...$domains): self
{
$resolver = static function (array &$route, array $domains): void {
foreach ($domains as $domain) {
if (1 === \preg_match('/^(?:([a-z]+)\:\/{2})?([^\/]+)?$/u', $domain, $m, \PREG_UNMATCHED_AS_NULL)) {
- Read upRead up
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 export
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function export(mixed $value, string $indent = ''): string
{
switch (true) {
case [] === $value:
return '[]';
Method buildCache
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildCache(RouteCollection $collection, bool $doCache): string
{
$dynamicRoutes = $dynamicVar = $staticRoutes = [];
$dynamicString = ":static function (string \$path): ?array {\n ";
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function placeholder(string $variable, string|array $regexp): self
{
if ($this->asRoute) {
$this->routes[$this->defaultIndex]['placeholders'][$variable] = $regexp;
} elseif (-1 === $this->defaultIndex && empty($this->groups)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 116.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function default(string $variable, mixed $default): self
{
if ($this->asRoute) {
$this->routes[$this->defaultIndex]['defaults'][$variable] = $default;
} elseif (-1 === $this->defaultIndex && empty($this->groups)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 116.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function injectGroups
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function injectGroups(string $prefix, array &$collection, int &$count): void
{
$unnamedRoutes = [];
foreach ($this->groups as $group) {
- Read upRead up
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 addRoute
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addRoute(RouteCollection $collection, Route $route, mixed $handler): RouteCollection
{
if (true !== $handler) {
if (empty($route->path)) {
throw new InvalidAnnotationException('Attributed method route path empty');
Method interpolate
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function interpolate(string $uriRoute, array $uriVars, array $parameters): string
{
$required = []; // Parameters required which are missing.
$replaces = self::URI_FIXERS;
Function resolveHandler
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function resolveHandler(mixed $handler, string $namespace = null): mixed
{
if (empty($namespace)) {
return $handler;
}
- Read upRead up
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"