daften/addressing-bundle

View on GitHub

Showing 20 of 213 total issues

Function initialize has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

    initialize: function () {
        countryCodeChange.initialize();

        $(document).ready(function () {
            $('.address-autocomplete-input').once('initiate-autocomplete').each(function () {
Severity: Minor
Found in Resources/public/js/addressGmapsAutocomplete.js - About 1 day 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 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    initialize: function () {
        countryCodeChange.initialize();

        $(document).ready(function () {
            $('.address-autocomplete-input').once('initiate-autocomplete').each(function () {
Severity: Major
Found in Resources/public/js/addressGmapsAutocomplete.js - About 4 hrs to fix

    Function initializeAutoComplete has 103 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function initializeAutoComplete($autocompleteField, oldAutocomplete) {
                var apiKey = $autocompleteField.attr('data-api-key');
                var language = $autocompleteField.attr('data-language');
                var allowedCountries = $autocompleteField.attr('data-allowed-countries').split('|');
    
    
    Severity: Major
    Found in Resources/public/js/addressGmapsAutocomplete.js - About 4 hrs to fix

      Function createAutoCompleteInstance has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  function createAutoCompleteInstance() {
      
                      var autocomplete,
                          componentForm = {
                              street_number: 'short_name',
      Severity: Major
      Found in Resources/public/js/addressGmapsAutocomplete.js - About 3 hrs to fix

        Function getValuesForPlain has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        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 - 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 getValuesForPlain has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        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 - About 1 hr to fix

          Function preSubmit has a Cognitive Complexity of 14 (exceeds 5 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

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

                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

                    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

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

                              CountryRepositoryInterface $countryRepository,
                              AddressFormatRepositoryInterface $addressFormatRepository,
                              SubdivisionRepositoryInterface $subdivisionRepository,
                              string $gmapsApiKey,
                              RequestStack $requestStack
                      Severity: Minor
                      Found in Service/GmapsAutocompleteService.php - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return new FieldOverrides([]);
                        Severity: Major
                        Found in Form/EventListener/AddressEmbeddableTypeSubscriber.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return $constraint->fieldOverrides;
                          Severity: Major
                          Found in Form/EventListener/AddressEmbeddableTypeSubscriber.php - About 30 mins to fix

                            Function getAddressDefault has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function getAddressDefault(AddressEmbeddable $addressEmbeddable): string
                                {
                                    $country_code = $addressEmbeddable->getCountryCode();
                                    $address_format = $this->addressFormatRepository->get($country_code);
                            
                            
                            Severity: Minor
                            Found in Service/AddressOutputService.php - About 25 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

                            Severity
                            Category
                            Status
                            Source
                            Language