vistart/yii2-models

View on GitHub

Showing 29 of 197 total issues

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

Avoid too many return statements within this method.
Open

            return $this->getIpv6Address();
Severity: Major
Found in traits/IPTrait.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return null;
    Severity: Major
    Found in traits/IPTrait.php - About 30 mins to fix

      Function removeIfExpired has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function removeIfExpired()
          {
              if ($this->getIsExpired() && !$this->getIsNewRecord()) {
                  if (($this->expiredRemovingCallback instanceof Closure || is_array($this->expiredRemovingCallback)) && is_callable($this->expiredRemovingCallback)) {
                      $result = call_user_func($this->expiredRemovingCallback, $this);
      Severity: Minor
      Found in traits/TimestampTrait.php - About 25 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 onReadAtChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function onReadAtChanged($event)
          {
              $sender = $event->sender;
              $raAttribute = $sender->readAtAttribute;
              if (!is_string($raAttribute)) {
      Severity: Minor
      Found in traits/MessageTrait.php - About 25 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 setRange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

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

          public function deregister()
          {
              if ($this->isNewRecord) {
                  return false;
              }
      Severity: Minor
      Found in traits/RegistrationTrait.php - About 25 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 normalizeSubsidiaryClass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function normalizeSubsidiaryClass($class)
          {
              if (empty($class) || !is_string($class)) {
                  return null;
              }
      Severity: Minor
      Found in traits/UserTrait.php - About 25 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