Showing 81 of 82 total issues

Function foldSelectionSet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function foldSelectionSet(SelectionSetNode $selectionSet, int $descend): array
    {
        $fields = [];

        foreach ($selectionSet->selections as $selectionNode) {
Severity: Minor
Found in src/Foundation/Webonyx/Input.php - 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

Function list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function list(iterable $routes, FieldResolve $event): array
    {
        $result = [];

        foreach ($routes as $route) {
Severity: Minor
Found in src/Extension/Routing/Subscribers/FieldResolveToActionSubscriber.php - 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

Function valueToScalar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function valueToScalar($value)
    {
        if (\is_scalar($value)) {
            return $value;
        }
Severity: Minor
Found in src/SDL/Support.php - 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

Function validateArrayDefaultValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function validateArrayDefaultValue(ArgumentDefinition $type, array $defaults): void
    {
        if (! $type->isList()) {
            $error = \sprintf('%s can not be initialized by List %s',
                $type, $this->valueToString($defaults)
Severity: Minor
Found in src/SDL/Reflection/Validation/Definitions/ArgumentValidator.php - 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

Function buildType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildType(NodeInterface $ast): bool
    {
        foreach ($ast->getChildren() as $child) {
            if ($child->getName() === 'T_NON_NULL') {
                if ($this->isList) {
Severity: Minor
Found in src/SDL/Reflection/Builder/Behavior/TypeIndicationBuilder.php - 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    protected function onCompile(NodeInterface $ast): bool
    {
        if ($ast->getName() === 'Relations') {
            foreach ($ast->getChildren() as $relation) {
                $name = $relation->getChild(0)->getValue();
Severity: Minor
Found in src/SDL/Reflection/Builder/Definitions/UnionBuilder.php and 1 other location - About 40 mins to fix
src/SDL/Reflection/Builder/Definitions/ObjectBuilder.php on lines 48..63

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 93.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    protected function onCompile(NodeInterface $ast): bool
    {
        if ($ast->getName() === 'Implements') {
            foreach ($ast->getChildren() as $child) {
                $name = $child->getChild(0)->getValue();
Severity: Minor
Found in src/SDL/Reflection/Builder/Definitions/ObjectBuilder.php and 1 other location - About 40 mins to fix
src/SDL/Reflection/Builder/Definitions/UnionBuilder.php on lines 46..61

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 93.

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

Further Reading

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

    protected function boot(NodeInterface $ast, Document $document): void
    {
        $this->ast = $ast;
        $this->document = $document;

Severity: Minor
Found in src/SDL/Reflection/Builder/Process/Compiler.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 resolvePreferType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function resolvePreferType(FieldDefinition $field, ResolveInfo $info): array
    {
        $types = [];

        foreach ($info->fieldNodes as $node) {
Severity: Minor
Found in src/Foundation/Webonyx/Input/PreferTypesLoader.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 preload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function preload(Dictionary $dictionary): void
    {
        foreach ($dictionary->all() as $type) {
            if ($type instanceof ObjectDefinition && $type->getNumberOfInterfaces() > 0) {
                $this->types[] = $this->loadType($type->getName());
Severity: Minor
Found in src/Foundation/Webonyx/Builder/SchemaBuilder.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 parseArgumentValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseArgumentValue(NodeInterface $ast): array
    {
        [$key, $value] = [null, null];

        foreach ($ast->getChildren() as $child) {
Severity: Minor
Found in src/SDL/Reflection/Builder/Invocations/DirectiveInvocationBuilder.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 getDirectives has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDirectives(string $name = null): iterable
    {
        foreach ($this->directives as $definitions) {
            foreach ((array)$definitions as $found => $invocation) {
                if ($name === null || $name === $found) {
Severity: Minor
Found in src/SDL/Base/Invocations/Directive/BaseDirectivesContainer.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 fromEnvironment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fromEnvironment(array $variables, array $values, \Closure $otherwise = null)
    {
        foreach ([$_ENV, $_SERVER] as $context) {
            foreach ($variables as $variable) {
                if (isset($context[$variable])) {
Severity: Minor
Found in src/Foundation/Application/Environment.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 runProxies has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function runProxies(array $children): iterable
    {
        $proxies = $this->traitConstructors(static::class, 'each');

        foreach ($children as $child) {
Severity: Minor
Found in src/GraphQL/AST/Node.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 complete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function complete(Document $document): Document
    {
        $this->load($document);

        $build = function (Definition $definition): void {
Severity: Minor
Found in src/SDL/Compiler.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

Avoid too many return statements within this method.
Open

                return self::ERROR_MESSAGE_RECURSION;
Severity: Major
Found in src/Json/Exception/Message.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return "\u{0000}";
    Severity: Major
    Found in src/Json/Json5/Ast/StringNode.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return self::ERROR_MESSAGE_UNSUPPORTED_TYPE;
      Severity: Major
      Found in src/Json/Exception/Message.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return "\u{000B}";
        Severity: Major
        Found in src/Json/Json5/Ast/StringNode.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return self::ERROR_MESSAGE_UNKNOWN;
          Severity: Major
          Found in src/Json/Exception/Message.php - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language