sehrgutesoftware/laravel5-api

View on GitHub

Showing 6 of 37 total issues

Controller has 34 functions (exceeds 20 allowed). Consider refactoring.
Open

class Controller extends IlluminateController
{
    /**
     * Maps request parameters to database columns.
     *
Severity: Minor
Found in src/Laravel5_Api/Controller.php - About 4 hrs to fix

    File Controller.php has 318 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace SehrGut\Laravel5_Api;
    
    use Illuminate\Database\Eloquent\Builder;
    Severity: Minor
    Found in src/Laravel5_Api/Controller.php - About 3 hrs to fix

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

          protected function replaceWithIdsOrClear($model)
          {
              if (!$this->config['replace_with_ids']) {
                  // Remove all relatives from all relations on the model
                  $model->setRelations([]);
      Severity: Minor
      Found in src/Laravel5_Api/Plugins/RelationSplitter.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

      Function validateInput has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function validateInput($only_present = false, $many = false)
          {
              $validator = $this->model_mapping->getValidatorFor($this->model);
              $raw_rules = $many ? $validator::getRulesMany() : $validator::getRules();
              $rules = $this->adaptRules($raw_rules);
      Severity: Minor
      Found in src/Laravel5_Api/Controller.php - About 35 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 filterByRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function filterByRequest($query, $mapping = null)
          {
              $mapping = $mapping ?: $this->key_mapping;
      
              foreach ($mapping as $request_key => $db_key) {
      Severity: Minor
      Found in src/Laravel5_Api/Controller.php - About 35 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 createResource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function createResource(array $attributes = null)
          {
              $input = is_null($attributes) ? $this->context->input : $attributes;
              $this->context->resource = new $this->model($input);
      
      
      Severity: Minor
      Found in src/Laravel5_Api/Controller.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