luyadev/luya-module-admin

View on GitHub
src/commands/CrudController.php

Summary

Maintainability
D
1 day
Test Coverage
F
44%

File CrudController.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace luya\admin\commands;

use luya\admin\base\BaseCrudController;
Severity: Minor
Found in src/commands/CrudController.php - About 3 hrs to fix

    CrudController has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CrudController extends BaseCrudController
    {
        /**
         * @var boolean Whether the core modules should be hidden from selection list or not.
         */
    Severity: Minor
    Found in src/commands/CrudController.php - About 2 hrs to fix

      Method actionCreate has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionCreate()
          {
              // 1. ask for module
              if ($this->moduleName === null) {
                  Console::clearScreenBeforeCursor();
      Severity: Major
      Found in src/commands/CrudController.php - About 2 hrs to fix

        Function generateModelContent has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generateModelContent($fileNamepsace, $className, $apiEndpoint, TableSchema $schema, $i18nFields)
            {
                $alias = Inflector::humanize(Inflector::camel2words($className));
                $dbTableName = $schema->fullName;
        
        
        Severity: Minor
        Found in src/commands/CrudController.php - About 2 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

        Function actionCreate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionCreate()
            {
                // 1. ask for module
                if ($this->moduleName === null) {
                    Console::clearScreenBeforeCursor();
        Severity: Minor
        Found in src/commands/CrudController.php - About 2 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 generateModelContent has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function generateModelContent($fileNamepsace, $className, $apiEndpoint, TableSchema $schema, $i18nFields)
            {
                $alias = Inflector::humanize(Inflector::camel2words($className));
                $dbTableName = $schema->fullName;
        
        
        Severity: Minor
        Found in src/commands/CrudController.php - About 1 hr to fix

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

              public function generateModelContent($fileNamepsace, $className, $apiEndpoint, TableSchema $schema, $i18nFields)
          Severity: Minor
          Found in src/commands/CrudController.php - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status