Covivo/mobicoop

View on GitHub

Showing 1,607 of 1,615 total issues

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

            } else {
                if (1 == $waypoint['candidate'] && (int) $waypoint['position'] > $steps['carpooler']) {
                    $steps['carpooler'] = (int) $waypoint['position'];
                } elseif (2 == $waypoint['candidate'] && (int) $waypoint['position'] > $steps['requester']) {
                    $steps['requester'] = (int) $waypoint['position'];
Severity: Minor
Found in api/src/Carpool/Service/ResultManager.php and 1 other location - About 45 mins to fix
api/src/Carpool/Service/ResultManager.php on lines 2678..2690

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

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

    public static function isCarpoolProofDataComplete(CarpoolProof $carpoolProof): bool
    {
        return
            !is_null($carpoolProof->getPickUpDriverAddress())
            && !is_null($carpoolProof->getPickUpDriverDate())
Severity: Minor
Found in api/src/Incentive/Validator/CarpoolProofValidator.php and 1 other location - About 45 mins to fix
api/src/Incentive/Validator/SubscriptionValidator.php on lines 85..94

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

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

    private function randomPassword()
    {
        $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
        $pass = []; // remember to declare $pass as an array
        $alphaLength = strlen($alphabet) - 1; // put the length -1 in cache
Severity: Minor
Found in api/src/Match/Service/MassMigrateManager.php and 1 other location - About 45 mins to fix
api/src/User/Service/UserManager.php on lines 1764..1775

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

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

Avoid deeply nested control flow statements.
Open

                                    if (is_null($ask->getCriteria()->getTueTime())) {
                                        break;
                                    }
Severity: Major
Found in api/src/Carpool/Service/ProofManager.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if (                                    // 1.2.2. First journey validation after published deadline
                                $this->isDateAfterPublishedDeadline($this->_today)
                            ) {
                                $this->_version = self::EEC_VERSION_IMPROVED;
                            }
    Severity: Major
    Found in api/src/Incentive/Entity/SubscriptionVersion.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                          if (is_null($ask->getCriteria()->getMonTime())) {
                                              break;
                                          }
      Severity: Major
      Found in api/src/Carpool/Service/ProofManager.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if (                                    // 1.2.1. Ld first journey realised before the published deadline
                                    $this->isDateBeforePublishedDeadline($this->_currentCommitmentJourney->getInitialProposal()->getCriteria()->getFromDate())
                                ) {
                                    $this->_version = self::EEC_VERSION_STANDARD;
                                }
        Severity: Major
        Found in api/src/Incentive/Entity/SubscriptionVersion.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                              if (is_null($ask->getCriteria()->getThuTime())) {
                                                  break;
                                              }
          Severity: Major
          Found in api/src/Carpool/Service/ProofManager.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (                                    // 1.2.1. Ld first journey realised after the published deadline
                                        $this->isDateAfterPublishedDeadline($this->_currentCommitmentJourney->getInitialProposal()->getCriteria()->getFromDate())
                                    ) {
                                        $this->_version = self::EEC_VERSION_IMPROVED;
                                    }
            Severity: Major
            Found in api/src/Incentive/Entity/SubscriptionVersion.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                                  if (is_null($ask->getCriteria()->getFriTime())) {
                                                      break;
                                                  }
              Severity: Major
              Found in api/src/Carpool/Service/ProofManager.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if ('' !== $tab[$i]) {
                                            $massPerson->{$setter}($tab[$i]);
                                        }
                Severity: Major
                Found in api/src/Match/Service/MassImportManager.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (Ad::ROLE_DRIVER_OR_PASSENGER == $ad->getRole()) {
                                                  // linking for the outward
                                                  $this->matchingRepository->linkOppositeMatchings($outwardProposal->getId());
                                                  if (!$ad->isOneWay()) {
                                                      // linking for the return
                  Severity: Major
                  Found in api/src/DataFixtures/BasicFixtures.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                        if (is_null($ask->getCriteria()->getSatTime())) {
                                                            break;
                                                        }
                    Severity: Major
                    Found in api/src/Carpool/Service/ProofManager.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (method_exists($personalAddress, $setter)) {
                                                  $personalAddress->{$setter}(strtoupper($tab[$i]));
                                              }
                      Severity: Major
                      Found in api/src/Match/Service/MassImportManager.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if (method_exists($workAddress, $setter)) {
                                                    $workAddress->{$setter}(strtoupper($tab[$i]));
                                                }
                        Severity: Major
                        Found in api/src/Match/Service/MassImportManager.php - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                              if (is_null($ask->getCriteria()->getSunTime())) {
                                                                  break;
                                                              }
                          Severity: Major
                          Found in api/src/Carpool/Service/ProofManager.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                        if (!$ad->isOneWay()) {
                                                            $returnProposal = $this->proposalManager->prepareProposal($this->proposalManager->get($outwardProposal->getProposalLinked()->getId()));
                                                            $this->matchingRepository->linkRelatedMatchings($outwardProposal->getId());
                                                        }
                            Severity: Major
                            Found in api/src/DataFixtures/BasicFixtures.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if (                                    // 1.2.1. First journey validation before published deadline
                                                          $this->isDateAfterPublishedDeadline($this->_today)
                                                      ) {
                                                          $this->_version = self::EEC_VERSION_STANDARD;
                                                      }
                              Severity: Major
                              Found in api/src/Incentive/Entity/SubscriptionVersion.php - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                                    if (is_null($ask->getCriteria()->getWedTime())) {
                                                                        break;
                                                                    }
                                Severity: Major
                                Found in api/src/Carpool/Service/ProofManager.php - About 45 mins to fix

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

                                                          if (isset($matching['request']->getFilters()['pickup']['sunMinPickupTime'], $matching['request']->getFilters()['pickup']['sunMaxPickupTime'])) {
                                                              $item->setSunCheck(true);
                                                              $item->setSunTime($proposal->getCriteria()->getSunTime());
                                                              $item->setTime($proposal->getCriteria()->getSunTime());
                                                              $item->setSunMarginDuration($proposal->getCriteria()->getSunMarginDuration());
                                  Severity: Major
                                  Found in api/src/Carpool/Service/ResultManager.php and 13 other locations - About 45 mins to fix
                                  api/src/Carpool/Service/ResultManager.php on lines 1008..1013
                                  api/src/Carpool/Service/ResultManager.php on lines 1014..1019
                                  api/src/Carpool/Service/ResultManager.php on lines 1020..1025
                                  api/src/Carpool/Service/ResultManager.php on lines 1026..1031
                                  api/src/Carpool/Service/ResultManager.php on lines 1032..1037
                                  api/src/Carpool/Service/ResultManager.php on lines 1038..1043
                                  api/src/Carpool/Service/ResultManager.php on lines 1532..1537
                                  api/src/Carpool/Service/ResultManager.php on lines 1538..1543
                                  api/src/Carpool/Service/ResultManager.php on lines 1544..1549
                                  api/src/Carpool/Service/ResultManager.php on lines 1550..1555
                                  api/src/Carpool/Service/ResultManager.php on lines 1556..1561
                                  api/src/Carpool/Service/ResultManager.php on lines 1562..1567
                                  api/src/Carpool/Service/ResultManager.php on lines 1568..1573

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

                                  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