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 — master ( 1679ce...0ad9a3 )
by Cristian
07:52
created

PermissionManagerServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 1
A setupRoutes() 0 7 1
A register() 0 10 1
1
<?php
2
namespace Backpack\PermissionManager;
3
4
use Illuminate\Routing\Router;
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Support\Facades\DB;
7
use Illuminate\Database\Eloquent\Model as Eloquent;
8
use Config;
9
10
class PermissionManagerServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Indicates if loading of the provider is deferred.
14
     *
15
     * @var bool
16
     */
17
    protected $defer = false;
18
    /**
19
     * Perform post-registration booting of services.
20
     *
21
     * @return void
22
     */
23
    public function boot()
24
    {
25
        // use the vendor configuration file as fallback
26
        echo '<pre>'; var_dump( __DIR__.'/config/laravel-permission.php'); echo '</pre>'; die();
0 ignored issues
show
Security Debugging Code introduced by
var_dump(__DIR__ . '/con...ravel-permission.php'); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
Coding Style Compatibility introduced by
The method boot() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
27
28
        $this->mergeConfigFrom(
0 ignored issues
show
Unused Code introduced by
$this->mergeConfigFrom(_... 'laravel-permission'); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
29
            __DIR__.'/config/laravel-permission.php', 'laravel-permission'
30
        );
31
32
        // publish config file
33
        $this->publishes([ __DIR__.'/config/laravel-permission.php' => config_path('laravel-permission.php'), ], 'config');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 123 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
34
    }
35
    /**
36
     * Define the routes for the application.
37
     *
38
     * @param  \Illuminate\Routing\Router  $router
39
     * @return void
40
     */
41
    public function setupRoutes(Router $router)
42
    {
43
        $router->group(['namespace' => 'Backpack\PermissionManager\app\Http\Controllers'], function($router)
44
        {
45
            require __DIR__.'/app/Http/routes.php';
46
        });
47
    }
48
    /**
49
     * Register any package services.
50
     *
51
     * @return void
52
     */
53
    public function register()
54
    {
55
        //$this->registerPermissions();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% 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...
56
        $this->setupRoutes($this->app->router);
0 ignored issues
show
Bug introduced by
Accessing router on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
57
58
        // use this if your package has a config file
59
         // config([
60
         //         'config/laravel-permission.php',
61
         // ]);
62
    }
63
64
}