sjeguedes/symfonyBM_API

View on GitHub

Showing 27 of 27 total issues

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

    public function listPhonesPerPartner(
        FilterRequestHandler $requestHandler,
        Partner $partner,
        RepresentationBuilder $representationBuilder,
        Request $request,
Severity: Major
Found in src/Controller/AdminPhoneController.php and 1 other location - About 6 hrs to fix
src/Controller/AdminClientController.php on lines 167..205

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

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 function listClientsPerPartner(
        FilterRequestHandler $requestHandler,
        Partner $partner,
        RepresentationBuilder $representationBuilder,
        Request $request,
Severity: Major
Found in src/Controller/AdminClientController.php and 1 other location - About 6 hrs to fix
src/Controller/AdminPhoneController.php on lines 165..203

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

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

Partner has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class Partner implements UserInterface, JWTUserInterface
{
    /**
     * Define an APi admin role (associated to a partner special account).
     */
Severity: Minor
Found in src/Entity/Partner.php - About 3 hrs to fix

    HTTPCache has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class HTTPCache
    {
        /**
         * Define which kind of HTTP cache is used for a particular response.
         */
    Severity: Minor
    Found in src/Entity/HTTPCache.php - About 2 hrs to fix

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

          public function showPartner(Partner $partner, HTTPCache $httpCache): JsonResponse
          {
              // Find partner details
              // An admin has access to all existing partners (including himself) details with this permission!
              $this->denyAccessUnlessGranted(
      Severity: Major
      Found in src/Controller/PartnerController.php and 1 other location - About 2 hrs to fix
      src/Controller/ClientController.php on lines 289..315

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

      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 function showClient(Client $client, HTTPCache $httpCache): JsonResponse
          {
              // Check view permission (Requested client must be associated to authenticated partner.)
              $this->denyAccessUnlessGranted(
                  ClientVoter::CAN_VIEW,
      Severity: Major
      Found in src/Controller/ClientController.php and 1 other location - About 2 hrs to fix
      src/Controller/PartnerController.php on lines 146..175

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

      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

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

      class Phone
      {
          /**
           * Define a set of phones categories.
           */
      Severity: Minor
      Found in src/Entity/Phone.php - About 2 hrs to fix

        Function loadSwaggerUI has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadSwaggerUI(userOptions = {}) {
          const data = JSON.parse(document.getElementById('swagger-data').innerText);
          const defaultOptions = {
            spec: data.spec,
            dom_id: '#swagger-ui',
        Severity: Minor
        Found in public/assets/bundles/nelmioapidoc/init-swagger-ui.js - About 1 hr to fix

          Method apply has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function apply(Request $request, ParamConverter $configuration): bool
              {
                  // Interrupt process if no uuid request attribute is found, or no special case matches!
                  if (null === $request->get('uuid') && !$this->setEntityUuidWithSpecialCase($request, $configuration)) {
                      return false;
          Severity: Minor
          Found in src/Services/API/ParamConverter/DoctrineCacheConverter.php - About 1 hr to fix

            Method loadValidatorMetadata has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function loadValidatorMetadata(ClassMetadata $metadata): void
                {
                    $metadata->addConstraint(
                        new UniqueEntity([
                            'fields' => ['brand', 'model']
            Severity: Minor
            Found in src/Entity/Phone.php - About 1 hr to fix

              Method listClients has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function listClients(
                      FilterRequestHandler $requestHandler,
                      RepresentationBuilder $representationBuilder,
                      Request $request,
                      HTTPCache $httpCache
              Severity: Minor
              Found in src/Controller/ClientController.php - About 1 hr to fix

                Method listPartners has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function listPartners(
                        FilterRequestHandler $requestHandler,
                        RepresentationBuilder $representationBuilder,
                        Request $request,
                        HTTPCache $httpCache
                Severity: Minor
                Found in src/Controller/AdminPartnerController.php - About 1 hr to fix

                  Method listOffersPerPhone has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function listOffersPerPhone(
                          FilterRequestHandler $requestHandler,
                          Phone $phone,
                          RepresentationBuilder $representationBuilder,
                          Request $request,
                  Severity: Minor
                  Found in src/Controller/AdminOfferController.php - About 1 hr to fix

                    Method loadData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function loadData(ObjectManager $manager): void
                        {
                            // Get existing companies sets
                            $data = DataProvider::PARTNER_COMPANY_SETS['references'];
                            // Use a row index per partner type (will be used for Proxy objects references)
                    Severity: Minor
                    Found in src/DataFixtures/PartnerFixtures.php - About 1 hr to fix

                      Method listPhones has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function listPhones(
                              FilterRequestHandler $requestHandler,
                              RepresentationBuilder $representationBuilder,
                              Request $request,
                              HTTPCache $httpCache
                      Severity: Minor
                      Found in src/Controller/PhoneController.php - About 1 hr to fix

                        Method loadData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function loadData(ObjectManager $manager): void
                            {
                                // Get all existing phones models
                                $data = DataProvider::PHONE_MODELS['references'];
                                // Use a row index per phone brand (will be used for Proxy objects references)
                        Severity: Minor
                        Found in src/DataFixtures/PhoneFixtures.php - About 1 hr to fix

                          Method listOffers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function listOffers(
                                  FilterRequestHandler $requestHandler,
                                  RepresentationBuilder $representationBuilder,
                                  Request $request,
                                  HTTPCache $httpCache
                          Severity: Minor
                          Found in src/Controller/AdminOfferController.php - About 1 hr to fix

                            Function invalidateHTTPCache has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function invalidateHTTPCache(UuidInterface $entityUuid, string $className, bool $isRemoval = false): void
                                {
                                    /** @var HTTPCacheRepository $httpCacheRepository */
                                    $httpCacheRepository = $this->entityManager->getRepository(HTTPCache::class);
                                    $results = $httpCacheRepository->findBy(['classShortName' =>  self::ALLOWED_ENTITIES[$className]]);
                            Severity: Minor
                            Found in src/Services/API/Event/Subscriber/DoctrineSubscriber.php - About 45 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

                            Function onKernelRequest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function onKernelRequest(RequestEvent $event): void
                                {
                                    if (!$event->isMasterRequest()) {
                                        return;
                                    }
                            Severity: Minor
                            Found in src/Services/API/Event/Listener/RequestListener.php - About 45 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

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

                                    FilterRequestHandler $requestHandler,
                                    Partner $partner,
                                    RepresentationBuilder $representationBuilder,
                                    Request $request,
                                    HTTPCache $httpCache
                            Severity: Minor
                            Found in src/Controller/AdminPhoneController.php - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language