vistart/yii2-models

View on GitHub

Showing 197 of 197 total issues

Method getContentRules has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getContentRules()
    {
        if (!$this->contentAttribute) {
            return [];
        }
Severity: Minor
Found in traits/BlameableTrait.php - About 1 hr to fix

    Function addOrCreateBlame has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addOrCreateBlame(&$blame = null, $user = null)
        {
            if (!is_string($this->multiBlamesClass)) {
                throw new InvalidConfigException('$multiBlamesClass must be specified if you want to use multiple blameable features.');
            }
    Severity: Minor
    Found in traits/MultipleBlameableTrait.php - About 55 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 resetConfirmation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function resetConfirmation()
        {
            $contentAttribute = $this->contentAttribute;
            if (!$contentAttribute) {
                return;
    Severity: Minor
    Found in traits/ConfirmationTrait.php - About 55 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 setIpAddress has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setIpAddress($ipAddress)
        {
            if (!$ipAddress || !$this->enableIP) {
                return null;
            }
    Severity: Minor
    Found in traits/IPTrait.php - About 55 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 getContentRules has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getContentRules()
        {
            if (!$this->contentAttribute) {
                return [];
            }
    Severity: Minor
    Found in traits/BlameableTrait.php - About 55 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 gets has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function gets($keys = null)
        {
            $noInitModel = static::buildNoInitModel();
            $query = static::find();
            if ($keys == null) {
    Severity: Minor
    Found in traits/MetaTrait.php - About 55 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php
    
    /**
     *  _   __ __ _____ _____ ___  ____  _____
     * | | / // // ___//_  _//   ||  __||_   _|
    Severity: Minor
    Found in models/BaseBlameableModel.php and 1 other location - About 55 mins to fix
    models/BaseRedisBlameableModel.php on lines 1..52

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 98.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php
    
    /**
     *  _   __ __ _____ _____ ___  ____  _____
     * | | / // // ___//_  _//   ||  __||_   _|
    Severity: Minor
    Found in models/BaseRedisBlameableModel.php and 1 other location - About 55 mins to fix
    models/BaseBlameableModel.php on lines 1..102

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 98.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        public static function findOneById($id, $throwException = true, $identity = null)
    Severity: Minor
    Found in traits/BlameableTrait.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        public function id($id, $like = false)
    Severity: Minor
    Found in traits/EntityQueryTrait.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

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

        public function deleteChildren()
        {
            $children = $this->children;
            if (empty($children)) {
                return true;
    Severity: Minor
    Found in traits/SelfBlameableTrait.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 buildRelation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function buildRelation($user, $other)
        {
            $relationQuery = static::find()->initiators($user)->recipients($other);
            $noInit = $relationQuery->noInitModel;
            $relation = $relationQuery->one();
    Severity: Minor
    Found in traits/UserRelationTrait.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 getRange has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRange()
        {
            $rangeAttribute = $this->rangeAttribute;
            if (!is_string($rangeAttribute)) {
                return null;
    Severity: Minor
    Found in traits/NotificationRangeTrait.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 onUpdateChildren has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function onUpdateChildren($event)
        {
            $sender = $event->sender;
            if (!is_string($sender->parentAttribute)) {
                return true;
    Severity: Minor
    Found in traits/SelfBlameableTrait.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 onDeleteChildren has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function onDeleteChildren($event)
        {
            $sender = $event->sender;
            if (!is_string($sender->parentAttribute)) {
                return true;
    Severity: Minor
    Found in traits/SelfBlameableTrait.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 enabledFields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function enabledFields()
        {
            $fields = parent::enabledFields();
            if (is_string($this->createdByAttribute)) {
                $fields[] = $this->createdByAttribute;
    Severity: Minor
    Found in traits/BlameableTrait.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

    The closing brace for the class must go on the next line after the body
    Open

    }
    Severity: Minor
    Found in models/BaseMetaModel.php by phpcodesniffer

    The closing brace for the class must go on the next line after the body
    Open

    }

    Property name "$_sourceRules" should not be prefixed with an underscore to indicate visibility
    Open

        private $_sourceRules = [];
    Severity: Minor
    Found in traits/RegistrationTrait.php by phpcodesniffer

    The closing brace for the class must go on the next line after the body
    Open

    }
    Severity
    Category
    Status
    Source
    Language