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 Setup Failed
Pull Request — development (#68)
by José
06:06
created

SearchController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A search() 0 21 2
1
<?php
2
3
namespace GiveBlood\Support\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use GiveBlood\Support\Http\Controllers\Controller;
7
8
use GiveBlood\Modules\Campaign\Campaign;
9
10
class SearchController extends Controller
11
{
12
    /**
13
     * Search for donors or campaigns
14
     *
15
     * @param  string $query
0 ignored issues
show
Bug introduced by
There is no parameter named $query. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
16
     * @return void
17
     */
18
    public function search(Request $request)
19
    {
20
        $campaigns = Campaign::where('title', 'like', '%'.$request->input('query').'%')
21
                               ->orWhere('description', 'like', '%'.$request->input('query').'%')
22
                               ->orderBy($request->input('orderBy'), $request->input('order'))
23
                               ->get();
24
25
        if (count($campaigns) > 0) {
26
            return response()->json(
0 ignored issues
show
Bug introduced by
The method json does only exist in Illuminate\Contracts\Routing\ResponseFactory, but not in Illuminate\Http\Response.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
27
                [
28
                'data' => $campaigns
29
                ], 200
30
            );
31
        } else {
32
            return response()->json(
33
                [
34
                'No content found. Try to search again!'
35
                ]
36
            );
37
        }
38
    }
39
}
40