gabrielbull/php-waredesk-api

View on GitHub

Showing 44 of 44 total issues

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

<?php

namespace Waredesk\Models\Product\Variant\Item;

use DateTime;
Severity: Major
Found in src/Models/Product/Variant/Item/Attribute.php and 1 other location - About 1 day to fix
src/Models/Product/Variant/Attribute.php on lines 1..93

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

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

<?php

namespace Waredesk\Models\Product\Variant;

use DateTime;
Severity: Major
Found in src/Models/Product/Variant/Attribute.php and 1 other location - About 1 day to fix
src/Models/Product/Variant/Item/Attribute.php on lines 1..93

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

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

Variant has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class Variant implements Entity, ReplaceableEntity, JsonSerializable
{
    public const WEIGHT_UNIT_IMPERIAL = 'imperial';
    public const WEIGHT_UNIT_METRIC = 'metric';
    public const LENGTH_UNIT_IMPERIAL = 'imperial';
Severity: Minor
Found in src/Models/Product/Variant.php - About 4 hrs to fix

    Function reset has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public function reset(array $data = null)
        {
            if ($data) {
                foreach ($data as $key => $value) {
                    switch ($key) {
    Severity: Minor
    Found in src/Models/Product/Variant.php - About 2 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 reset has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function reset(array $data = null)
        {
            if ($data) {
                foreach ($data as $key => $value) {
                    switch ($key) {
    Severity: Major
    Found in src/Models/Product/Variant.php - About 2 hrs to fix

      RequestHandler has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class RequestHandler
      {
          private $mockHandler;
          private $accessToken;
          private $apiUrl;
      Severity: Minor
      Found in src/RequestHandler.php - About 2 hrs to fix

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

        <?php
        
        namespace Waredesk\Mappers\Product\Variant\Item;
        
        use DateTime;
        Severity: Major
        Found in src/Mappers/Product/Variant/Item/AttributeMapper.php and 4 other locations - About 2 hrs to fix
        src/Mappers/CategoryMapper.php on lines 1..30
        src/Mappers/Inventory/Item/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/CodeMapper.php on lines 1..32

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

        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 5 locations. Consider refactoring.
        Open

        <?php
        
        namespace Waredesk\Mappers\Inventory\Item;
        
        use DateTime;
        Severity: Major
        Found in src/Mappers/Inventory/Item/AttributeMapper.php and 4 other locations - About 2 hrs to fix
        src/Mappers/CategoryMapper.php on lines 1..30
        src/Mappers/Product/Variant/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/CodeMapper.php on lines 1..32
        src/Mappers/Product/Variant/Item/AttributeMapper.php on lines 1..30

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

        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 5 locations. Consider refactoring.
        Open

        <?php
        
        namespace Waredesk\Mappers\Product\Variant;
        
        use DateTime;
        Severity: Major
        Found in src/Mappers/Product/Variant/CodeMapper.php and 4 other locations - About 2 hrs to fix
        src/Mappers/CategoryMapper.php on lines 1..30
        src/Mappers/Inventory/Item/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/Item/AttributeMapper.php on lines 1..30

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

        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 5 locations. Consider refactoring.
        Open

        <?php
        
        namespace Waredesk\Mappers;
        
        use Waredesk\Mapper;
        Severity: Major
        Found in src/Mappers/CategoryMapper.php and 4 other locations - About 2 hrs to fix
        src/Mappers/Inventory/Item/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/CodeMapper.php on lines 1..32
        src/Mappers/Product/Variant/Item/AttributeMapper.php on lines 1..30

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

        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 5 locations. Consider refactoring.
        Open

        <?php
        
        namespace Waredesk\Mappers\Product\Variant;
        
        use DateTime;
        Severity: Major
        Found in src/Mappers/Product/Variant/AttributeMapper.php and 4 other locations - About 2 hrs to fix
        src/Mappers/CategoryMapper.php on lines 1..30
        src/Mappers/Inventory/Item/AttributeMapper.php on lines 1..30
        src/Mappers/Product/Variant/CodeMapper.php on lines 1..32
        src/Mappers/Product/Variant/Item/AttributeMapper.php on lines 1..30

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

        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

        File Variant.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace Waredesk\Models\Product;
        
        use DateTime;
        Severity: Minor
        Found in src/Models/Product/Variant.php - About 2 hrs to fix

          Method request has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function request(string $method, string $endpoint, array $headers = [], $params = null)
              {
                  try {
                      $enhancedHeaders = $this->enhanceHeaders($headers);
                      $params = $this->encodeParams($params);
          Severity: Minor
          Found in src/RequestHandler.php - About 2 hrs to fix

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

                public function reset(array $data = null)
                {
                    if ($data) {
                        foreach ($data as $key => $value) {
                            switch ($key) {
            Severity: Minor
            Found in src/Models/Inventory/Item.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

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

                public function reset(array $data = null)
                {
                    if ($data) {
                        foreach ($data as $key => $value) {
                            switch ($key) {
            Severity: Major
            Found in src/Models/Product/Variant/Code.php and 3 other locations - About 1 hr to fix
            src/Models/Inventory/Item/Activity.php on lines 57..83
            src/Models/Inventory/Item/Attribute.php on lines 57..83
            src/Models/Product/Variant/Price.php on lines 54..80

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

            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 4 locations. Consider refactoring.
            Open

                public function reset(array $data = null)
                {
                    if ($data) {
                        foreach ($data as $key => $value) {
                            switch ($key) {
            Severity: Major
            Found in src/Models/Product/Variant/Price.php and 3 other locations - About 1 hr to fix
            src/Models/Inventory/Item/Activity.php on lines 57..83
            src/Models/Inventory/Item/Attribute.php on lines 57..83
            src/Models/Product/Variant/Code.php on lines 57..83

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

            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 4 locations. Consider refactoring.
            Open

                public function reset(array $data = null)
                {
                    if ($data) {
                        foreach ($data as $key => $value) {
                            switch ($key) {
            Severity: Major
            Found in src/Models/Inventory/Item/Attribute.php and 3 other locations - About 1 hr to fix
            src/Models/Inventory/Item/Activity.php on lines 57..83
            src/Models/Product/Variant/Code.php on lines 57..83
            src/Models/Product/Variant/Price.php on lines 54..80

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

            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 4 locations. Consider refactoring.
            Open

                public function reset(array $data = null)
                {
                    if ($data) {
                        foreach ($data as $key => $value) {
                            switch ($key) {
            Severity: Major
            Found in src/Models/Inventory/Item/Activity.php and 3 other locations - About 1 hr to fix
            src/Models/Inventory/Item/Attribute.php on lines 57..83
            src/Models/Product/Variant/Code.php on lines 57..83
            src/Models/Product/Variant/Price.php on lines 54..80

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

            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

            Method map has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function map(Variant $variant, $data): Variant
                {
                    $finalData = [];
                    foreach ($data as $key => $value) {
                        switch ($key) {
            Severity: Minor
            Found in src/Mappers/Product/VariantMapper.php - About 1 hr to fix

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

                  public function reset(array $data = null)
                  {
                      if ($data) {
                          foreach ($data as $key => $value) {
                              switch ($key) {
              Severity: Minor
              Found in src/Models/Product.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

              Severity
              Category
              Status
              Source
              Language