timegridio/timegrid

View on GitHub

Showing 390 of 390 total issues

Terminating statement must be indented to the same level as the CASE body
Open

            break;

Avoid too many return statements within this method.
Open

        return redirect()->route('user.agenda', '#'.$appointment->code);
Severity: Major
Found in app/Http/Controllers/User/AgendaController.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return view('guest.appointment.show', compact('appointment'));
Severity: Major
Found in app/Http/Controllers/User/AgendaController.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return redirect()->route('manager.business.agenda.index', compact('business'));
Severity: Major
Found in app/Http/Controllers/User/AgendaController.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return $this->value;
Severity: Major
Found in app/Models/Preference.php - About 30 mins to fix

Missing class import via use statement (line '129', column '25').
Open

        $interval = new \DateInterval('P1D');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method getTimes has a boolean flag argument $preferredTimezone, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getTimes($businessId, $serviceId, $date, $preferredTimezone = false)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Missing class import via use statement (line '62', column '117').
Open

            $startAt = new \DateTime($appointment->start_at->timezone($business->timezone)->toDateTimeString(), new \DateTimeZone($business->timezone));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '63', column '116').
Open

            $endAt = new \DateTime($appointment->finish_at->timezone($business->timezone)->toDateTimeString(), new \DateTimeZone($business->timezone));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '233', column '23').
Open

            throw new \Exception('Email view does not exist: '.$key);
Severity: Minor
Found in app/TG/TransMail.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '130', column '26').
Open

        $daterange = new \DatePeriod($start, $interval, $end->addDay());

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '63', column '26').
Open

            $endAt = new \DateTime($appointment->finish_at->timezone($business->timezone)->toDateTimeString(), new \DateTimeZone($business->timezone));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '62', column '28').
Open

            $startAt = new \DateTime($appointment->start_at->timezone($business->timezone)->toDateTimeString(), new \DateTimeZone($business->timezone));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Function value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function value()
    {
        switch ($this->type) {
            case 'string':
                return (string) $this->value;
Severity: Minor
Found in app/Models/Preference.php - About 25 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 cast has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function cast($value, $type)
    {
        switch ($type) {
            case 'bool':
                $value = boolval($value);
Severity: Minor
Found in app/Traits/Preferenceable.php - About 25 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 using static access to class '\Illuminate\Support\Facades\Broadcast' in method 'boot'.
Open

        Broadcast::routes();

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid unused parameters such as '$router'.
Open

        ], function ($router) {

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid using static access to class '\App\Models\User' in method 'create'.
Open

        $user = User::create([
            'username' => md5("{$data['name']}/{$data['email']}"),
            'name'     => $data['name'],
            'email'    => $data['email'],
            'password' => bcrypt($data['password']),

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Illuminate\Support\Facades\Storage' in method 'recallStatements'.
Open

        if (!Storage::exists($this->getStatementsFile($businessId))) {

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\JavaScript' in method 'getAvailability'.
Open

        JavaScript::put([
            'language'  => $this->getActiveLanguage($business->locale),
            'startDate' => $startFromDate->toDateString(),
            'endDate'   => $startFromDate->addDays($days)->toDateString(),
        ]);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Severity
Category
Status
Source
Language