repman-io/repman

View on GitHub

Showing 140 of 140 total issues

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

<?php

declare(strict_types=1);

namespace Buddy\Repman\Migrations;
Severity: Major
Found in src/Migrations/Version20200723105216.php and 4 other locations - About 1 hr to fix
src/Migrations/Version20200421143358.php on lines 1..36
src/Migrations/Version20200507052339.php on lines 1..36
src/Migrations/Version20200604151104.php on lines 1..36
src/Migrations/Version20200724131616.php on lines 1..36

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

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

    public function profile(Request $request): Response
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
        $oauthTokens = $this->userQuery->findAllOAuthTokens($this->getUser()->id());

Severity: Minor
Found in src/Controller/UserController.php - About 1 hr to fix

    Method buildForm has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function buildForm(FormBuilderInterface $builder, array $options): void
        {
            $builder
                ->add('formUrl', HiddenType::class, [
                    'attr' => ['class' => 'addPackageFormUrl'],
    Severity: Minor
    Found in src/Form/Type/Organization/AddPackageType.php - About 1 hr to fix

      Method packages has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function packages(string $organizationId, \DateTimeImmutable $till, int $limit = 100, int $offset = 0): array
          {
              return array_map(function (array $data): Package {
                  return new Package(
                      $data['type'],
      Severity: Minor
      Found in src/Query/Admin/TelemetryQuery/DbalTelemetryQuery.php - About 1 hr to fix

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

            public function __construct(string $id, string $email, string $password, string $status, bool $emailConfirmed, string $emailConfirmToken, $roles, $organizations, bool $emailScanResult, string $timezone)
        Severity: Major
        Found in src/Security/Model/User.php - About 1 hr to fix

          Method scan has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function scan(Package $package): void
              {
                  $packageName = $package->name();
                  $result = [];
                  $status = ScanResult::STATUS_OK;
          Severity: Minor
          Found in src/Service/Security/PackageScanner/SensioLabsPackageScanner.php - About 1 hr to fix

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

                public function register(Request $request): Response
                {
                    $this->ensureRegistrationIsEnabled();
            
                    $form = $this->createForm(RegisterType::class);
            Severity: Minor
            Found in src/Controller/RegistrationController.php - About 1 hr to fix

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

                  private function findDistribution(Package $package): string
                  {
                      $packageName = $package->name();
                      $latestReleasedVersion = $package->latestReleasedVersion();
              
              
              Severity: Minor
              Found in src/Service/Security/PackageScanner/SensioLabsPackageScanner.php - About 1 hr to fix

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

                        string $type,
                        ?\DateTimeImmutable $lastRelease,
                        ?\DateTimeImmutable $lastSync,
                        ?\DateTimeImmutable $lastScan,
                        bool $hasError,
                Severity: Major
                Found in src/Service/Telemetry/Entry/Package.php - About 1 hr to fix

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

                      private function getAdvisories(): array
                      {
                          $advisories = [];
                          foreach ($this->getDatabase() as $file) {
                              if (!$file->isFile() || $file->getExtension() !== 'yaml') {
                  Severity: Minor
                  Found in src/Service/Security/SecurityChecker/SensioLabsSecurityChecker.php - About 1 hr to fix

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

                        public function getDetailsById(string $id): Option
                        {
                            $data = $this->connection->fetchAssociative(
                                'SELECT
                                    id,
                    Severity: Minor
                    Found in src/Query/User/PackageQuery/DbalPackageQuery.php - About 1 hr to fix

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

                          public function findAll(string $organizationId, int $limit = 20, int $offset = 0): array
                          {
                              return array_map(function (array $data): Package {
                                  return $this->hydratePackage($data);
                                  }, $this->connection->fetchAllAssociative(
                      Severity: Minor
                      Found in src/Query/Api/PackageQuery/DbalPackageQuery.php - About 1 hr to fix

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

                            public function syncSuccess(string $name, string $description, string $latestReleasedVersion, array $encounteredVersions, array $encounteredLinks, \DateTimeImmutable $latestReleaseDate): void
                            {
                                $this->setName($name);
                                $this->description = $description;
                                $this->latestReleasedVersion = $latestReleasedVersion;
                        Severity: Minor
                        Found in src/Entity/Organization/Package.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 getAdvisories has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function getAdvisories(): array
                            {
                                $advisories = [];
                                foreach ($this->getDatabase() as $file) {
                                    if (!$file->isFile() || $file->getExtension() !== 'yaml') {
                        Severity: Minor
                        Found in src/Service/Security/SecurityChecker/SensioLabsSecurityChecker.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 organizations has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function organizations(int $limit = 100, int $offset = 0): array
                            {
                                return array_map(function (array $data): Organization {
                                    return new Organization(
                                        $data['id'],
                        Severity: Minor
                        Found in src/Query/Admin/TelemetryQuery/DbalTelemetryQuery.php - About 1 hr to fix

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

                              public function getById(string $id): Option
                              {
                                  $data = $this->connection->fetchAssociative(
                                      'SELECT
                                          id,
                          Severity: Minor
                          Found in src/Query/User/PackageQuery/DbalPackageQuery.php - About 1 hr to fix

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

                                public function settings(Organization $organization, Request $request): Response
                                {
                                    $renameForm = $this->createForm(ChangeNameType::class, ['name' => $organization->name()]);
                                    $renameForm->handleRequest($request);
                                    if ($renameForm->isSubmitted() && $renameForm->isValid()) {
                            Severity: Minor
                            Found in src/Controller/OrganizationController.php - About 1 hr to fix

                              Method getById has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function getById(string $organizationId, string $id): Option
                                  {
                                      $data = $this->connection->fetchAssociative(
                                          'SELECT
                                              id,
                              Severity: Minor
                              Found in src/Query/Api/PackageQuery/DbalPackageQuery.php - About 1 hr to fix

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

                                <?php
                                
                                declare(strict_types=1);
                                
                                namespace Buddy\Repman\Form\Type\Organization;
                                Severity: Major
                                Found in src/Form/Type/Organization/GenerateTokenType.php and 2 other locations - About 1 hr to fix
                                src/Form/Type/Organization/ChangeNameType.php on lines 1..38
                                src/Form/Type/Organization/GenerateApiTokenType.php on lines 1..35

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

                                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

                                <?php
                                
                                declare(strict_types=1);
                                
                                namespace Buddy\Repman\Form\Type\Organization;
                                Severity: Major
                                Found in src/Form/Type/Organization/GenerateApiTokenType.php and 2 other locations - About 1 hr to fix
                                src/Form/Type/Organization/ChangeNameType.php on lines 1..38
                                src/Form/Type/Organization/GenerateTokenType.php on lines 1..35

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

                                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