NFarrington/vatsim-url-shortener

View on GitHub

Showing 32 of 37 total issues

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

    public function up()
    {
        if (DB::connection()->getName() == 'mysql') {
            DB::statement('ALTER TABLE news CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL');
            DB::statement('ALTER TABLE url_analytics DROP FOREIGN KEY url_analytics_url_id_foreign');
Severity: Major
Found in database/migrations/2020_07_02_000000_doctrine_support.php and 1 other location - About 1 wk to fix
database/migrations/2020_07_02_000000_doctrine_support.php on lines 165..305

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

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 down()
    {
        if (DB::connection()->getName() == 'mysql') {
            DB::statement('ALTER TABLE domain_organization DROP FOREIGN KEY FK_58E115F1115F0EE5');
            DB::statement('ALTER TABLE domain_organization DROP FOREIGN KEY FK_58E115F132C8A3DE');
Severity: Major
Found in database/migrations/2020_07_02_000000_doctrine_support.php and 1 other location - About 1 wk to fix
database/migrations/2020_07_02_000000_doctrine_support.php on lines 13..158

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

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

    public function up()
    {
        if (DB::connection()->getName() == 'mysql') {
            DB::statement('ALTER TABLE news CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL');
            DB::statement('ALTER TABLE url_analytics DROP FOREIGN KEY url_analytics_url_id_foreign');
Severity: Major
Found in database/migrations/2020_07_02_000000_doctrine_support.php - About 5 hrs to fix

Method down has 138 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function down()
    {
        if (DB::connection()->getName() == 'mysql') {
            DB::statement('ALTER TABLE domain_organization DROP FOREIGN KEY FK_58E115F1115F0EE5');
            DB::statement('ALTER TABLE domain_organization DROP FOREIGN KEY FK_58E115F132C8A3DE');
Severity: Major
Found in database/migrations/2020_07_02_000000_doctrine_support.php - About 5 hrs to fix

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

<?php

namespace App\Console\Commands;

use Barryvdh\LaravelIdeHelper\Factories;
Severity: Major
Found in app/Console/Commands/FactoryHelper.php and 1 other location - About 5 hrs to fix
app/Console/Commands/EntityFactoryMetadata.php on lines 1..40

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

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

<?php

namespace App\Console\Commands;

use Barryvdh\LaravelIdeHelper\Factories;
Severity: Major
Found in app/Console/Commands/EntityFactoryMetadata.php and 1 other location - About 5 hrs to fix
app/Console/Commands/FactoryHelper.php on lines 1..40

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

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

User has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

class User extends Entity implements Authenticatable
{
    use RecordsCreatedAt, RecordsUpdatedAt, RoutesNotifications;

    protected array $trackedProperties = [
Severity: Minor
Found in app/Entities/User.php - About 4 hrs to fix

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

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
Severity: Major
Found in app/Notifications/PrefixApplicationApprovedNotification.php and 1 other location - About 3 hrs to fix
app/Notifications/PrefixApplicationRejectedNotification.php on lines 1..45

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

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

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
Severity: Major
Found in app/Notifications/PrefixApplicationRejectedNotification.php and 1 other location - About 3 hrs to fix
app/Notifications/PrefixApplicationApprovedNotification.php on lines 1..45

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

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

File UrlController.php has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers\Platform;

use App\Entities\Domain;
Severity: Minor
Found in app/Http/Controllers/Platform/UrlController.php - About 3 hrs to fix

Method verifyLogin has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function verifyLogin(Request $request)
    {
        try {
            $accessToken = $this->provider->getAccessToken(
                'authorization_code',
Severity: Major
Found in app/Http/Controllers/Platform/VatsimConnectLoginController.php - About 2 hrs to fix

Method handle has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle()
    {
        $this->simpleDbClient = app(SimpleDbClient::class);
        $this->urlRepository = app(UrlRepository::class);

Severity: Minor
Found in app/Console/Commands/SyncSimpleDb.php - About 1 hr to fix

Function store has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function store(Request $request)
    {
        $user = $request->user();
        $attributes = $this->getValidationFactory()->make(
            $request->all(),
Severity: Minor
Found in app/Http/Controllers/Platform/UrlController.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

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

    public function getUsers(int $roleId = null): array
    {
        if ($roleId === null) {
            return $this->organizationUsers
                ->map(fn (OrganizationUser $organizationUser) => $organizationUser->getUser())
Severity: Major
Found in app/Entities/Organization.php and 1 other location - About 1 hr to fix
app/Entities/User.php on lines 305..317

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

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 getOrganizations(int $roleId = null): array
    {
        if ($roleId === null) {
            return $this->userOrganizations
                ->map(fn (OrganizationUser $organizationUser) => $organizationUser->getOrganization())
Severity: Major
Found in app/Entities/User.php and 1 other location - About 1 hr to fix
app/Entities/Organization.php on lines 128..140

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

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

    public function update(Request $request, Url $url)
    {
        $this->authorize('update', $url);

        $attributes = $this->validate(
Severity: Minor
Found in app/Http/Controllers/Platform/UrlController.php - About 1 hr to fix

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

    public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();

Severity: Minor
Found in app/Events/Doctrine/DoctrineEventMapper.php - About 1 hr to fix

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

    public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();

Severity: Minor
Found in app/Events/Doctrine/DoctrineEventMapper.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 findByUserOrTheirOrganizations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function findByUserOrTheirOrganizations(
        User $user,
        string $orderBy = 'id',
        string $order = 'ASC',
        int $perPage = null,
Severity: Minor
Found in app/Repositories/UrlRepository.php - About 1 hr to fix

Function verifyLogin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function verifyLogin(Request $request)
    {
        try {
            $accessToken = $this->provider->getAccessToken(
                'authorization_code',
Severity: Minor
Found in app/Http/Controllers/Platform/VatsimConnectLoginController.php - About 55 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