esteit/shipping-calculator

View on GitHub

Showing 104 of 104 total issues

File DhlHandler.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace EsteIt\ShippingCalculator\Handler;

use EsteIt\ShippingCalculator\Address;
Severity: Minor
Found in src/Handler/DhlHandler.php - About 2 hrs to fix

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

    class IParcelHandler implements HandlerInterface, ValidationHandlerInterface
    {
        /**
         * @var array
         */
    Severity: Minor
    Found in src/Handler/IParcelHandler.php - About 2 hrs to fix

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

      class AramexHandler implements HandlerInterface, ValidationHandlerInterface
      {
          /**
           * @var array
           */
      Severity: Minor
      Found in src/Handler/AramexHandler.php - About 2 hrs to fix

        File AsendiaHandler.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace EsteIt\ShippingCalculator\Handler;
        
        use EsteIt\ShippingCalculator\Address;
        Severity: Minor
        Found in src/Handler/AsendiaHandler.php - About 2 hrs to fix

          DhlHandler has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class DhlHandler implements HandlerInterface, ValidationHandlerInterface
          {
              /**
               * @var array
               */
          Severity: Minor
          Found in src/Handler/DhlHandler.php - About 2 hrs to fix

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

                protected function createImportCountriesNormalizer()
                {
                    return function (Options $options, $value) {
                        $normalized = [];
                        foreach ($value as $country) {
            Severity: Major
            Found in src/Handler/IParcelHandler.php and 2 other locations - About 2 hrs to fix
            src/Handler/AramexHandler.php on lines 305..321
            src/Handler/AsendiaHandler.php on lines 302..318

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

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

                protected function createImportCountriesNormalizer()
                {
                    return function (Options $options, $value) {
                        $normalized = [];
                        foreach ($value as $country) {
            Severity: Major
            Found in src/Handler/AramexHandler.php and 2 other locations - About 2 hrs to fix
            src/Handler/AsendiaHandler.php on lines 302..318
            src/Handler/IParcelHandler.php on lines 301..317

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

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

                protected function createImportCountriesNormalizer()
                {
                    return function (Options $options, $value) {
                        $normalized = [];
                        foreach ($value as $country) {
            Severity: Major
            Found in src/Handler/AsendiaHandler.php and 2 other locations - About 2 hrs to fix
            src/Handler/AramexHandler.php on lines 305..321
            src/Handler/IParcelHandler.php on lines 301..317

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

            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 __construct has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct(array $options)
                {
                    $math = new NativeMath();
                    $resolver = new OptionsResolver();
                    $weightConverter = new WeightConverter($math);
            Severity: Minor
            Found in src/Handler/IParcelHandler.php - About 1 hr to fix

              Method getConfigTreeBuilder has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getConfigTreeBuilder()
                  {
                      $builder = new TreeBuilder();
                      $rootNode = $builder->root('dhl');
              
              
              Severity: Minor
              Found in src/Configuration/DhlConfiguration.php - About 1 hr to fix

                Method __construct has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct(array $options)
                    {
                        $math = new NativeMath();
                        $resolver = new OptionsResolver();
                        $weightConverter = new WeightConverter($math);
                Severity: Minor
                Found in src/Handler/AramexHandler.php - About 1 hr to fix

                  Method __construct has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function __construct(array $options)
                      {
                          $math = new NativeMath();
                          $resolver = new OptionsResolver();
                          $weightConverter = new WeightConverter($math);
                  Severity: Minor
                  Found in src/Handler/DhlHandler.php - About 1 hr to fix

                    Method getConfigTreeBuilder has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getConfigTreeBuilder()
                        {
                            $builder = new TreeBuilder();
                            $rootNode = $builder->root('asendia');
                    
                    
                    Severity: Minor
                    Found in src/Configuration/AsendiaConfiguration.php - About 1 hr to fix

                      Method __construct has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function __construct(array $options)
                          {
                              $math = new NativeMath();
                              $resolver = new OptionsResolver();
                              $dimensionsNormalizer = new DimensionsNormalizer($math);
                      Severity: Minor
                      Found in src/Handler/AsendiaHandler.php - About 1 hr to fix

                        Method getConfigTreeBuilder has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getConfigTreeBuilder()
                            {
                                $builder = new TreeBuilder();
                                $rootNode = $builder->root('aramex');
                        
                        
                        Severity: Minor
                        Found in src/Configuration/AramexConfiguration.php - About 1 hr to fix

                          Method getConfigTreeBuilder has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getConfigTreeBuilder()
                              {
                                  $builder = new TreeBuilder();
                                  $rootNode = $builder->root('i-parcel');
                          
                          
                          Severity: Minor
                          Found in src/Configuration/IParcelConfiguration.php - About 1 hr to fix

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

                                    $weightPricesNormalizer = function (Options $options, $weightPrices) {

                            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 $weightPricesNormalizer. Keep variable name length under 20.
                            Open

                                    $weightPricesNormalizer = function (Options $options, $weightPrices) {
                            Severity: Minor
                            Found in src/Handler/Dhl/ZoneCalculator.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

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

                                public function validateMaximumPerimeter(Package $package)
                                {
                                    $dimensions = $package->getDimensions();
                                    $perimeter = $this->getPerimeterCalculator()->calculate($dimensions);
                                    $maxPerimeter = $this->getLengthConverter()->convert($this->get('maximum_perimeter'), $this->get('dimensions_unit'), $dimensions->getUnit());
                            Severity: Major
                            Found in src/Handler/AramexHandler.php and 1 other location - About 1 hr to fix
                            src/Handler/IParcelHandler.php on lines 169..177

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

                            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 EsteIt\ShippingCalculator\Event;
                            
                            use EsteIt\ShippingCalculator\Calculator\CalculatorInterface;
                            Severity: Major
                            Found in src/Event/AfterHandleEvent.php and 1 other location - About 1 hr to fix
                            src/Event/BeforeHandleEvent.php on lines 1..62

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language