yiisoft/yii2

View on GitHub

Showing 787 of 2,467 total issues

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

    protected function detectSearchAttributeTypes()
    {
        $model = $this->getSearchModel();

        $attributeTypes = [];
Severity: Minor
Found in framework/data/DataFilter.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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function init()
    {
        parent::init();
        if ($this->message !== null) {
            return;
Severity: Minor
Found in framework/validators/UniqueValidator.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 asPercentStringFallback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function asPercentStringFallback($value, $decimals = null)
    {
        if (empty($value)) {
            $value = 0;
        }
Severity: Minor
Found in framework/i18n/Formatter.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 validateMimeType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateMimeType($file)
    {
        $fileMimeType = $this->getMimeTypeByFile($file->tempName);
        if ($fileMimeType === null) {
            return false;
Severity: Minor
Found in framework/validators/FileValidator.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 prepareConditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function prepareConditions($targetAttribute, $model, $attribute)
    {
        if (is_array($targetAttribute)) {
            if ($this->allowArray) {
                throw new InvalidConfigException('The "targetAttribute" property must be configured as a string.');
Severity: Minor
Found in framework/validators/ExistValidator.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 fallbackFormat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fallbackFormat($pattern, $args, $locale)
    {
        if (($tokens = self::tokenizePattern($pattern)) === false) {
            $this->_errorCode = -1;
            $this->_errorMessage = 'Message pattern is invalid.';
Severity: Minor
Found in framework/i18n/MessageFormatter.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function run()
    {
        if (($content = $this->getCachedContent()) !== false) {
            echo $content;
        } elseif ($this->cache instanceof CacheInterface) {
Severity: Minor
Found in framework/widgets/FragmentCache.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

Avoid too many return statements within this method.
Open

                    return $supported;
Severity: Major
Found in framework/filters/ContentNegotiator.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return false;
    Severity: Major
    Found in framework/rbac/DbManager.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return null;
      Severity: Major
      Found in framework/di/Instance.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return call_user_func($type, $value);
        Severity: Major
        Found in framework/behaviors/AttributeTypecastBehavior.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return false;
          Severity: Major
          Found in framework/behaviors/SluggableBehavior.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false;
            Severity: Major
            Found in framework/filters/AccessRule.php - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return [];
              Severity: Major
              Found in framework/assets/yii.validation.js - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return (string) $value;
                Severity: Major
                Found in framework/behaviors/AttributeTypecastBehavior.php - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return true;
                  Severity: Major
                  Found in framework/assets/yii.activeForm.js - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $this->languages[$language];
                    Severity: Major
                    Found in framework/filters/ContentNegotiator.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return false;
                      Severity: Major
                      Found in framework/rbac/DbManager.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return false;
                        Severity: Major
                        Found in framework/rbac/PhpManager.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $definition;
                          Severity: Major
                          Found in framework/di/Container.php - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language