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

Completed
Push — development ( f5a703...65354c )
by José
03:44
created

Handler   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
lcom 0
cbo 4
dl 0
loc 107
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A unauthenticated() 0 10 2
A report() 0 4 1
B render() 0 28 3
A invalidJson() 0 4 1
1
<?php
2
3
namespace DoeSangue\Exceptions;
4
5
use Exception;
6
use Illuminate\Auth\AuthenticationException;
7
use Illuminate\Validation\ValidationException;
8
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
10
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
11
12
class Handler extends ExceptionHandler
13
{
14
    /**
15
     * A list of the exception types that are not reported.
16
     *
17
     * @var array
18
     */
19
    protected $dontReport = [
20
        /*\Illuminate\Auth\AuthenticationException::class,
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21
        \Illuminate\Auth\Access\AuthorizationException::class,
22
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
23
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
24
        \Illuminate\Session\TokenMismatchException::class,
25
        \Illuminate\Validation\ValidationException::class,
26
        */
27
    ];
28
29
    /**
30
     * A list of the inputs that are never flashed for validation exceptions.
31
     * @var array
32
     */
33
    protected $dontFlash = [
34
      'password',
35
      'password_confirmation',
36
    ];
37
38
    /**
39
     * Report or log an exception.
40
     *
41
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
42
     *
43
     * @param \Exception $exception
44
     */
45
    public function report(Exception $exception)
46
    {
47
        parent::report($exception);
48
    }
49
50
    /**
51
     * Render an exception into an HTTP response.
52
     *
53
     * @param \Illuminate\Http\Request $request
54
     * @param \Exception               $exception
55
     *
56
     * @return \Illuminate\Http\Response
57
     */
58
    public function render($request, Exception $exception)
59
    {
60
        // Validate 404 exceptions.
61
        if ($exception instanceof NotFoundHttpException) {
62
            return response()->json(
63
                [
64
                'error' => [
65
                    'description' => 'Invalid URI',
66
                    'messages' => [ ]
67
                ]
68
                ], 404
69
            );
70
        }
71
72
        // Method not allowed exception handler
73
        if ($exception instanceof MethodNotAllowedHttpException) {
74
            return response()->json(
75
                [
76
                'error' => [
77
                    'description' => 'Method Not Allowed',
78
                    'messages' => [ ]
79
                ]
80
                ], 405
81
            );
82
        }
83
84
        return parent::render($request, $exception);
85
    }
86
87
    /**
88
     * Convert a validation exception into a JSON response.
89
     *
90
     * @param \Illuminate\Http\Request $request
91
     * @param \Illuminate\Validation\ValidationException $exception
92
     * @return \Illuminate\Http\JsonResponse
93
     */
94
    protected function invalidJson($request, ValidationException $exception)
95
    {
96
      return response()->json($exception->errors(), $exception->status);
97
    }
98
99
    /**
100
     * Convert an authentication exception into an unauthenticated response.
101
     *
102
     * @param \Illuminate\Http\Request                 $request
103
     * @param \Illuminate\Auth\AuthenticationException $exception
104
     * @return \Illuminate\Http\Response
105
     */
106
    protected function unauthenticated($request, AuthenticationException $exception)
107
    {
108
        if ($request->expectsJson()) {
109
110
            return response()->json([ 'error' => 'Unauthenticated.' ], 401);
111
112
        }
113
114
        // return redirect()->guest('login');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
115
    }
116
117
118
}
119