skqr/hateoas

View on GitHub

Showing 662 of 662 total issues

Avoid excessively long variable names like $paginationLinksSerializer. Keep variable name length under 20.
Open

    private $paginationLinksSerializer;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $topLevelLinkSerializer. Keep variable name length under 20.
Open

        Serializer\TopLevelLinksSerializer $topLevelLinkSerializer,
Severity: Minor
Found in JsonApi/DocumentSerializer.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

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

    protected function setRelationships(
        \ReflectionClass $class,
        ResourceEntityInterface $entity,
        array $relationships
    )
Severity: Minor
Found in Entity/AltersEntities.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 hydrate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function hydrate(Params $params, array &$resourceObject)
    {
        if (empty($resourceObject[self::LINKS])) {
            return;
        } elseif (!is_array($resourceObject[self::LINKS])) {
Severity: Minor
Found in JsonApi/Request/ResourceLinksHydrant.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 mergeLinkedResources has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function mergeLinkedResources(array &$champion, array $challenger)
    {
        static $key = 'linked';

        if (isset($champion[$key]) || isset($challenger[$key])) {
Severity: Minor
Found in JsonApi/Merge/Blender.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 serializeTransationObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function serializeTransationObject(array $resourceTranslations)
    {
        $translations = [];

        foreach (
Severity: Minor
Found in JsonApi/Request/TranslationsParser.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 mergeResourceMeta has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function mergeResourceMeta(array &$champion, array $challenger)
    {
        static $key = 'meta';

        if (isset($champion[$key]) || isset($challenger[$key])) {
Severity: Minor
Found in JsonApi/Merge/Blender.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 serialize has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function serialize()
    {
        $metadata = $this->resource->getMetadata();
        $json = [
            'id' => $this->resource->id,
Severity: Minor
Found in JsonApi/Serializer/ResourceObjectSerializer.php - About 1 hr to fix

    Method parse has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function parse(Request $request)
        {
            $content = $request->getContent();
    
            if (!empty($content) && self::HTTP_DELETE == $request->getMethod()) {
    Severity: Minor
    Found in JsonApi/Request/Parser.php - About 1 hr to fix

      The class Params has 16 fields. Consider redesigning Params to keep the number of fields under 15.
      Open

      class Params
      {
          const ASCENDING_ORDER = Criteria::ASC,
              DESCENDING_ORDER = Criteria::DESC,
              DEFAULT_PAGE_OFFSET = 0,
      Severity: Minor
      Found in JsonApi/Request/Params.php by phpmd

      TooManyFields

      Since: 0.1

      Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

      Example

      class Person {
         protected $one;
         private $two;
         private $three;
         [... many more fields ...]
      }

      Source https://phpmd.org/rules/codesize.html#toomanyfields

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

          private function processToManyRelationship(
              ResourceCollectionInterface $resources,
              $relationshipName,
              array &$linkedResources,
              LinkedResourcesSerialization $resourcesSerialization
      Severity: Minor
      Found in JsonApi/Serializer/LinkedResourcesSerializer.php - About 1 hr to fix

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

            public function parse(Request $request, Params $params, array $body)
            {
                $entityData = [];
        
                if (empty($body[$params->primaryType])) {
        Severity: Minor
        Found in JsonApi/Request/UpdateBodyParser.php - About 1 hr to fix

          Function parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parse(Request $request, Params $params, array $body)
              {
                  $translations = [];
          
                  if (
          Severity: Minor
          Found in JsonApi/Request/TranslationsParser.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 parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parse(Request $request, Params $params, array $body)
              {
                  $entityData = [];
          
                  if (empty($body[$params->primaryType])) {
          Severity: Minor
          Found in JsonApi/Request/CreateBodyParser.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 hydrate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function hydrate(Params $params, array &$resourceObject)
              {
                  if (empty($resourceObject[self::LINKS])) {
                      return;
                  } elseif (!is_array($resourceObject[self::LINKS])) {
          Severity: Minor
          Found in JsonApi/Request/ResourceLinksHydrant.php - About 1 hr to fix

            Method processToOneRelationship has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function processToOneRelationship(
                    ResourceCollectionInterface $resources,
                    $relationshipName,
                    array &$linkedResources,
                    LinkedResourcesSerialization $resourcesSerialization
            Severity: Minor
            Found in JsonApi/Serializer/LinkedResourcesSerializer.php - About 1 hr to fix

              Function serialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function serialize()
                  {
                      $metadata = $this->resource->getMetadata();
                      $json = [
                          'id' => $this->resource->id,
              Severity: Minor
              Found in JsonApi/Serializer/ResourceObjectSerializer.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 serialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function serialize(JsonApi\Document $document)
                  {
                      $json = [];
              
                      if ($document->i18n) {
              Severity: Minor
              Found in JsonApi/Serializer/TranslationsMetadataSerializer.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 __construct has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      ResourceEntityMapper $resourceEntityMapper,
                      DocNavigator $docNavigator,
                      FilterParser $filterParser,
                      PaginationParser $paginationParser,
                      BodyParser $bodyParser,
              Severity: Major
              Found in JsonApi/Request/Parser.php - About 1 hr to fix

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

                    public function parse(Request $request, Params $params, array $body)
                    {
                        $translations = [];
                
                        if (
                Severity: Minor
                Found in JsonApi/Request/TranslationsParser.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language