NFarrington/vatsim-url-shortener

View on GitHub

Showing 21 of 37 total issues

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

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

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

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

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

    public function format(array $record): string
    {
        if (empty($record['datetime'])) {
            $record['datetime'] = gmdate('c');
        }
Severity: Minor
Found in app/Logging/EcsFormatter.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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        SimpleDbClient $simpleDbClient,
        EntityManagerInterface $entityManager,
        UrlRepository $urlRepository,
        DomainRepository $domainRepository,
        OrganizationRepository $organizationRepository,
Severity: Minor
Found in app/Http/Controllers/Platform/UrlController.php - About 45 mins to fix

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

        User $user,
        string $orderBy = 'id',
        string $order = 'ASC',
        int $perPage = null,
        int $page = null
Severity: Minor
Found in app/Repositories/UrlRepository.php - About 35 mins to fix

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

        User $user,
        string $orderBy = 'id',
        string $order = 'ASC',
        int $perPage = null,
        int $page = null
Severity: Minor
Found in app/Repositories/DomainRepository.php - About 35 mins to fix

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

        User $user,
        string $orderBy = 'id',
        string $order = 'ASC',
        int $perPage = null,
        int $page = null
Severity: Minor
Found in app/Repositories/OrganizationRepository.php - About 35 mins to fix

Function createUrl has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function createUrl(User $user, Domain $domain)
    {
        if ($domain->isPublic()) {
            return true;
        }
Severity: Minor
Found in app/Policies/DomainPolicy.php - About 35 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

Avoid too many return statements within this method.
Open

        return redirect()->route('platform.urls.index')
            ->with('success', 'URL created.');
Severity: Major
Found in app/Http/Controllers/Platform/UrlController.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return redirect()->intended($this->redirectPath());
Severity: Major
Found in app/Http/Controllers/Platform/VatsimConnectLoginController.php - About 30 mins to fix
Severity
Category
Status
Source
Language