linpax/microphp-framework

View on GitHub

Showing 94 of 1,083 total issues

Form has 52 functions (exceeds 20 allowed). Consider refactoring.
Open

class Form
{
    /**
     * Render label tag
     *
Severity: Major
Found in src/form/Form.php - About 7 hrs to fix

    File Form.php has 401 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php /** MicroForm */
    
    namespace Micro\Form;
    
    use Micro\Web\Html\Html;
    Severity: Minor
    Found in src/form/Form.php - About 5 hrs to fix

      Function run has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function run($model, $client = false)
          {
              $elements = explode(',', str_replace(' ', '', array_shift($this->rule)));
              $name = array_shift($this->rule);
      
      
      Severity: Minor
      Found in src/validator/Validator.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

      Function validate has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function validate(IFormModel $model)
          {
              foreach ($this->elements AS $element) {
                  if (!$model->checkAttributeExists($element)) {
                      /** @var UploadedFileInterface[] $files */
      Severity: Minor
      Found in src/validator/FileValidator.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

      Function loadInjection has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          private function loadInjection($name)
          {
              $options = self::$CONFIG['components'][$name];
      
              if (empty($options['class']) || !class_exists($options['class'])) {
      Severity: Minor
      Found in src/base/Injector.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 publish has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function publish()
          {
              foreach ($this->required AS $require) {
                  if (!in_array($require, $this->published, true) && class_exists($require)) {
                      $this->published[] = $require;
      Severity: Minor
      Found in src/web/Asset.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

      Model has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      abstract class Model extends FormModel implements IModel
      {
          /** @var string $primaryKey Primary key on table */
          public static $primaryKey = 'id';
          /** @var string $tableName Table name */
      Severity: Minor
      Found in src/mvc/models/Model.php - About 2 hrs to fix

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

            public static function recurseCopyIfEdited($src = '', $dst = '', array $excludes = ['php'])
            {
                if (!is_dir($dst) && (!mkdir($dst) && !is_dir($dst))) {
                    throw new Exception('Copy dir error, access denied for path: '.$dst);
                }
        Severity: Minor
        Found in src/file/FileHelper.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 __get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __get($name)
            {
                /** @var array $relation */
                if ($relation = $this->relations()->get($name)) {
                    if (empty($this->cacheRelations[$name])) {
        Severity: Minor
        Found in src/mvc/models/Model.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 parse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function parse($uri, $method = 'GET')
            {
                // default path
                if ($uri === '/' || $uri === '' || $uri === '/default') {
                    return '/default';
        Severity: Minor
        Found in src/web/Router.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

        Threads has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class Threads
        {
            /** @var string $name thread name */
            private $name;
            /** @var integer $pid process ID */
        Severity: Minor
        Found in src/cli/Threads.php - About 2 hrs to fix

          Function update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              final public function update($where = null)
              {
                  if ($this->isNewRecord()) {
                      return false;
                  }
          Severity: Minor
          Found in src/mvc/models/Model.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 dirSize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function dirSize($dirName)
              {
                  $totalSize = 0;
                  if ($dirStream = opendir($dirName)) {
                      while (false !== ($fileName = readdir($dirStream))) {
          Severity: Minor
          Found in src/file/FileHelper.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 __construct has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct(array $args = [])
              {
                  parent::__construct($args);
          
                  if (empty($args['data'])) {
          Severity: Minor
          Found in src/widget/ListViewWidget.php - About 1 hr to fix

            Function applyFilters has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                public function applyFilters($action, $isPre = true, array $filters = [], $data = null)
                {
                    if (!$filters) {
                        return $data;
                    }
            Severity: Minor
            Found in src/mvc/controllers/Controller.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 validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                public function validate(IFormModel $model)
                {
                    foreach ($this->elements AS $element) {
                        if (!$model->checkAttributeExists($element)) {
                            $this->errors[] = 'Parameter '.$element.' not defined in class '.get_class($model);
            Severity: Minor
            Found in src/validator/StringValidator.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 __construct has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct(array $args = [])
                {
                    parent::__construct($args);
            
                    if (!array_key_exists('data', $args)) {
            Severity: Minor
            Found in src/widget/GridViewWidget.php - About 1 hr to fix

              Function matchUser has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function matchUser($rule)
                  {
                      if (empty($rule['users'])) {
                          return true;
                      }
              Severity: Minor
              Found in src/filter/AccessFilter.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 action has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function action($name = 'index')
                  {
                      // Set widgetStack for widgets
                      if (empty($GLOBALS['widgetStack'])) {
                          $GLOBALS['widgetStack'] = [];
              Severity: Minor
              Found in src/mvc/controllers/ViewController.php - About 1 hr to fix

                Method run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function run($model, $client = false)
                    {
                        $elements = explode(',', str_replace(' ', '', array_shift($this->rule)));
                        $name = array_shift($this->rule);
                
                
                Severity: Minor
                Found in src/validator/Validator.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language