yiisoft/yii2

View on GitHub

Showing 787 of 2,467 total issues

Function getActiveValidators has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getActiveValidators($attribute = null)
    {
        $activeAttributes = $this->activeAttributes();
        if ($attribute !== null && !in_array($attribute, $activeAttributes, true)) {
            return [];
Severity: Minor
Found in framework/base/Model.php - About 45 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 createRules has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function createRules()
    {
        $only = array_flip($this->only);
        $except = array_flip($this->except);
        $patterns = $this->extraPatterns + $this->patterns;
Severity: Minor
Found in framework/rest/UrlRule.php - About 45 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 loadTableConstraints has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadTableConstraints($tableName, $returnType)
    {
        static $sql = <<<'SQL'
SELECT
    `kcu`.`CONSTRAINT_NAME` AS `name`,
Severity: Minor
Found in framework/db/mysql/Schema.php - About 45 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

Method handleHhvmError has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function handleHhvmError($code, $message, $file, $line, $context, $backtrace)
Severity: Minor
Found in framework/base/ErrorHandler.php - About 45 mins to fix

    Function alias has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function alias($alias)
        {
            if (empty($this->from) || count($this->from) < 2) {
                list($tableName) = $this->getTableNameAndAlias();
                $this->from = [$alias => $tableName];
    Severity: Minor
    Found in framework/db/ActiveQuery.php - About 45 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 register has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function register()
        {
            if (!$this->_registered) {
                ini_set('display_errors', false);
                set_exception_handler([$this, 'handleException']);
    Severity: Minor
    Found in framework/base/ErrorHandler.php - About 45 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 getColumnType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getColumnType($type)
        {
            if ($type instanceof ColumnSchemaBuilder) {
                $type = $type->__toString();
            }
    Severity: Minor
    Found in framework/db/QueryBuilder.php - About 45 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 normalizeTableRowData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function normalizeTableRowData($table, $columns)
        {
            if ($columns instanceof Query) {
                return $columns;
            }
    Severity: Minor
    Found in framework/db/pgsql/QueryBuilder.php - About 45 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 begin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function begin($isolationLevel = null)
        {
            if ($this->db === null) {
                throw new InvalidConfigException('Transaction::db must be set.');
            }
    Severity: Minor
    Found in framework/db/Transaction.php - About 45 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 commit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function commit()
        {
            if (!$this->getIsActive()) {
                throw new Exception('Failed to commit transaction: transaction was inactive.');
            }
    Severity: Minor
    Found in framework/db/Transaction.php - About 45 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 serialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function serialize($data)
        {
            if ($data instanceof Model && $data->hasErrors()) {
                return $this->serializeModelErrors($data);
            } elseif ($data instanceof Arrayable) {
    Severity: Minor
    Found in framework/rest/Serializer.php - About 45 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 handleFatalError has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function handleFatalError()
        {
            unset($this->_memoryReserve);
    
            if (isset($this->_workingDirectory)) {
    Severity: Minor
    Found in framework/base/ErrorHandler.php - About 45 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

    Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, $previous = null)
    Severity: Minor
    Found in framework/base/ErrorException.php - About 45 mins to fix

      Function loadTableChecks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function loadTableChecks($tableName)
          {
              $sql = $this->db->createCommand('SELECT `sql` FROM `sqlite_master` WHERE name = :tableName', [
                  ':tableName' => $tableName,
              ])->queryScalar();
      Severity: Minor
      Found in framework/db/sqlite/Schema.php - About 45 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 parseString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private function parseString($value, &$i)
          {
              $isQuoted = $value[$i] === '"';
              $stringEndChars = $isQuoted ? ['"'] : [$this->delimiter, '}'];
              $result = '';
      Severity: Minor
      Found in framework/db/pgsql/ArrayParser.php - About 45 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 phpTypecast has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function phpTypecast($value)
          {
              if ($this->dimension > 0) {
                  if ($this->disableArraySupport) {
                      return $value;
      Severity: Minor
      Found in framework/db/pgsql/ColumnSchema.php - About 45 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 populate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function populate($rows)
          {
              if (empty($rows)) {
                  return [];
              }
      Severity: Minor
      Found in framework/db/ActiveQuery.php - About 45 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 handleException has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handleException($exception)
          {
              if ($exception instanceof ExitException) {
                  return;
              }
      Severity: Minor
      Found in framework/base/ErrorHandler.php - About 45 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 initColumns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function initColumns()
          {
              if (empty($this->columns)) {
                  $this->guessColumns();
              }
      Severity: Minor
      Found in framework/grid/GridView.php - About 45 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 registerAssetFiles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function registerAssetFiles($view)
          {
              $manager = $view->getAssetManager();
              foreach ($this->js as $js) {
                  if (is_array($js)) {
      Severity: Minor
      Found in framework/web/AssetBundle.php - About 45 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