Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Failed
Push — add-tests ( b5d574...b02a3b )
by Pedro
11:16
created

BaseTestClass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 50
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 13 1
A getPackageProviders() 0 6 1
A invokeMethod() 0 7 1
A setupUserCreateRequest() 0 7 1
1
<?php
2
3
namespace Backpack\CRUD\Tests;
4
5
use Backpack\Basset\BassetServiceProvider;
6
use Backpack\CRUD\BackpackServiceProvider;
7
use Backpack\CRUD\Tests\config\TestsServiceProvider;
8
use Illuminate\Support\Facades\Route;
9
use Orchestra\Testbench\TestCase;
10
11
abstract class BaseTestClass extends TestCase
12
{
13
    /**
14
     * Setup the test environment.
15
     *
16
     * @return void
17
     */
18
    protected function setUp(): void
19
    {
20
        parent::setUp();
21
22
        Route::group([
23
            (array) config('backpack.base.web_middleware', 'web'),
24
            (array) config('backpack.base.middleware_key', 'admin'),
25
            'prefix' => config('backpack.base.route_prefix', 'admin'),
26
        ],
27
            function () {
28
                Route::get('articles/{id}/show/{detail}', ['as' => 'article.show.detail', 'action' => 'Backpack\CRUD\Tests\config\Http\Controllers\ArticleCrudController@detail']);
29
                Route::crud('users', 'Backpack\CRUD\Tests\config\Http\Controllers\UserCrudController');
30
                Route::crud('articles', 'Backpack\CRUD\Tests\config\Http\Controllers\ArticleCrudController');
31
            }
32
        );
33
    }
34
35
    protected function getPackageProviders($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

35
    protected function getPackageProviders(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        return [
38
            BassetServiceProvider::class,
39
            BackpackServiceProvider::class,
40
            TestsServiceProvider::class,
41
        ];
42
    }
43
44
    private function setupUserCreateRequest()
0 ignored issues
show
Unused Code introduced by
The method setupUserCreateRequest() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
45
    {
46
        $request = request()->create('/admin/users/create', 'POST', ['name' => 'foo']);
47
        $request->setRouteResolver(function () use ($request) {
48
            return (new Route('POST', 'admin/users/create', ['UserCrudController', 'create']))->bind($request);
0 ignored issues
show
Unused Code introduced by
The call to Illuminate\Support\Facades\Route::__construct() has too many arguments starting with 'POST'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
            return (/** @scrutinizer ignore-call */ new Route('POST', 'admin/users/create', ['UserCrudController', 'create']))->bind($request);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
The call to Illuminate\Support\Facades\Route::bind() has too few arguments starting with binder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
            return (new Route('POST', 'admin/users/create', ['UserCrudController', 'create']))->/** @scrutinizer ignore-call */ bind($request);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
Are you sure the usage of new Illuminate\Support\F...eate'))->bind($request) targeting Illuminate\Support\Facades\Route::bind() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
49
        });
50
        $this->crudPanel->setRequest($request);
51
    }
52
53
    // allow us to run crud panel private/protected methods like `inferFieldTypeFromDbColumnType`
54
    public function invokeMethod(&$object, $methodName, array $parameters = [])
55
    {
56
        $reflection = new \ReflectionClass(get_class($object));
57
        $method = $reflection->getMethod($methodName);
58
        $method->setAccessible(true);
59
60
        return $method->invokeArgs($object, $parameters);
61
    }
62
}
63