daften/addressing-bundle

View on GitHub

Showing 213 of 213 total issues

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

        SubdivisionRepositoryInterface $subdivisionRepository,

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

    protected $gmapsAutocompleteService;

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

    private $addressEmbeddableTypeSubscriber;
Severity: Minor
Found in Form/Type/AddressEmbeddableType.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

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

        EventSubscriberInterface $addressEmbeddableTypeSubscriber

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

Method preSetData has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function preSetData(FormEvent $event): void
    {
        /** @var AddressEmbeddable $address */
        $address = $event->getData();
        $form = $event->getForm();
Severity: Minor
Found in Form/EventListener/AddressEmbeddableTypeSubscriber.php - About 1 hr to fix

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

        public function preSubmit(FormEvent $event): void
        {
            $data = $event->getData();
            if (!is_array($data) || !array_key_exists('countryCode', $data)) {
                return;
    Severity: Minor
    Found in Form/EventListener/AddressEmbeddableTypeSubscriber.php - About 1 hr to fix

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

          protected function getValuesForDefault(AddressEmbeddable $addressEmbeddable, AddressFormat $address_format) {
              $values = [];
              foreach (AddressField::getAll() as $field) {
                  $getter = 'get' . ucfirst($field);
                  $values[$field] = $addressEmbeddable->$getter();
      Severity: Minor
      Found in Service/AddressOutputService.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 preSetData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function preSetData(FormEvent $event): void
          {
              /** @var AddressEmbeddable $address */
              $address = $event->getData();
              $form = $event->getForm();
      Severity: Minor
      Found in Form/EventListener/AddressEmbeddableTypeSubscriber.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 initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          initialize: function () {
              $(document).ready(function () {
                  $('.address-embeddable').once('initiate-country-code-change').each(function () {
                      var id = $(this).attr('id');
      
      
      Severity: Minor
      Found in Resources/public/js/countryCodeChange.js - About 1 hr to fix

        Avoid using undefined variables such as '$replacements' which will lead to PHP notices.
        Open

                    $replacements[$field] = htmlspecialchars($values[$field], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
        Severity: Minor
        Found in Service/AddressOutputService.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

        Avoid using undefined variables such as '$replacements' which will lead to PHP notices.
        Open

                return $replacements;
        Severity: Minor
        Found in Service/AddressOutputService.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

        Avoid using undefined variables such as '$replacements' which will lead to PHP notices.
        Open

                $replacements['country'] = htmlspecialchars($countries[$country_code], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
        Severity: Minor
        Found in Service/AddressOutputService.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

        Avoid using undefined variables such as '$address' which will lead to PHP notices.
        Open

                    $use_local_name = Locale::matchCandidates($address->getLocale(), $subdivision->getLocale());
        Severity: Minor
        Found in Service/AddressOutputService.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

        Function fillInAddress has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                        function fillInAddress(place)
                        {
                            if (typeof place.name === 'undefined') {
                                place.name = getPlaceName(place);
                            }
        Severity: Minor
        Found in Resources/public/js/addressGmapsAutocomplete.js - About 1 hr to fix

          Function getFieldOverrides has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getFieldOverrides(FormInterface $form): FieldOverrides
              {
                  if (!$this->validator) {
                      return new FieldOverrides([]);
                  }
          Severity: Minor
          Found in Form/EventListener/AddressEmbeddableTypeSubscriber.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 getFieldOverrides has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getFieldOverrides(FormInterface $form): FieldOverrides
              {
                  if (!$this->validator) {
                      return new FieldOverrides([]);
                  }
          Severity: Minor
          Found in Form/EventListener/AddressEmbeddableTypeSubscriber.php - About 1 hr to fix

            The parameter $address_format is not named in camelCase.
            Open

                protected function getValuesForPlain(AddressEmbeddable $addressEmbeddable, AddressFormat $address_format) {
                    $values = [];
                    foreach (AddressField::getAll() as $field) {
                        $getter = 'get' . ucfirst($field);
                        $values[$field] = $addressEmbeddable->$getter();
            Severity: Minor
            Found in Service/AddressOutputService.php by phpmd

            CamelCaseParameterName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name parameters.

            Example

            class ClassName {
                public function doSomething($user_name) {
                }
            }

            Source

            The parameter $address_format is not named in camelCase.
            Open

                protected function getValuesForDefault(AddressEmbeddable $addressEmbeddable, AddressFormat $address_format) {
                    $values = [];
                    foreach (AddressField::getAll() as $field) {
                        $getter = 'get' . ucfirst($field);
                        $values[$field] = $addressEmbeddable->$getter();
            Severity: Minor
            Found in Service/AddressOutputService.php by phpmd

            CamelCaseParameterName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name parameters.

            Example

            class ClassName {
                public function doSomething($user_name) {
                }
            }

            Source

            The class AddressEmbeddableTypeSubscriber has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
            Open

            class AddressEmbeddableTypeSubscriber implements EventSubscriberInterface
            {
                /**
                 * @var CountryRepositoryInterface
                 */

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    FormFactoryInterface $factory,
                    CountryRepositoryInterface $countryRepository,
                    AddressFormatRepositoryInterface $addressFormatRepository,
                    SubdivisionRepositoryInterface $subdivisionRepository,
                    ValidatorInterface $validator = null
            Severity: Minor
            Found in Form/EventListener/AddressEmbeddableTypeSubscriber.php - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language