foothing/laravel-wrappr

View on GitHub

Showing 6 of 6 total issues

Function parsePattern has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function parsePattern($pattern) {
        $count = 0;
        $pattern = preg_replace("/\{(.*?)\}/", "[0-9]+", $pattern, 1, $count);
        if ($count > 1) {
            throw new \Exception("Pattern cannot contain more than one resource identifiers.");
Severity: Minor
Found in src/Foothing/Wrappr/Installer/Parser.php - About 3 hrs 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

Method parsePattern has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function parsePattern($pattern) {
        $count = 0;
        $pattern = preg_replace("/\{(.*?)\}/", "[0-9]+", $pattern, 1, $count);
        if ($count > 1) {
            throw new \Exception("Pattern cannot contain more than one resource identifiers.");
Severity: Minor
Found in src/Foothing/Wrappr/Installer/Parser.php - About 1 hr to fix

    Function install has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function install() {
            if ( ! empty($this->collection) ) {
                foreach ($this->collection as $route) {
                    if ($route->verb == '*') {
                        foreach ($this->allowed as $verb) {
    Severity: Minor
    Found in src/Foothing/Wrappr/Installer/RouteInstaller.php - About 1 hr 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

    Method handle has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        function handle($request, \Closure $next, $permissions, $resource = null, $id = null) {
    Severity: Minor
    Found in src/Foothing/Wrappr/Middleware/CheckRoute.php - About 35 mins to fix

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

          function handle($request, \Closure $next, $permissions, $resource = null, $id = null) {
      
              $route = new Route();
              $route->permissions = $permissions;
              $route->resourceName = $resource;
      Severity: Minor
      Found in src/Foothing/Wrappr/Middleware/CheckRoute.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 contains has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function contains($permissionName, $resourceName = null, $resourceId = null) {
              $permission = new Permission($permissionName, $resourceName, $resourceId);
              foreach ($this->getAllowed() as $allowed) {
                  if ($allowed->equals($permission)) {
                      return true;
      Severity: Minor
      Found in src/Foothing/Wrappr/Permissions/Collection.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

      Severity
      Category
      Status
      Source
      Language