tuyakhov/yii2-notifications

View on GitHub

Showing 6 of 6 total issues

Function send has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function send($recipients, $notifications)
    {
        if (!is_array($recipients)) {
            /**
             * @var $recipients NotifiableInterface[]
Severity: Minor
Found in src/Notifier.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

Method send has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function send($recipients, $notifications)
    {
        if (!is_array($recipients)) {
            /**
             * @var $recipients NotifiableInterface[]
Severity: Minor
Found in src/Notifier.php - About 1 hr to fix

    Method send has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function send(NotifiableInterface $recipient, NotificationInterface $notification)
        {
            /** @var TelegramMessage $message */
            $message = $notification->exportFor('telegram');
            $text = $message->body;
    Severity: Minor
    Found in src/channels/TelegramChannel.php - About 1 hr to fix

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

          public function detach()
          {
              if ($this->owner) {
                  foreach ($this->notifications as $event => $notifications) {
                      if (!is_array($notifications)) {
      Severity: Minor
      Found in src/behaviors/NotifiableBehavior.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 broadcastOn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function broadcastOn()
          {
              $channels = [];
              $methods = get_class_methods($this);
              foreach ($methods as $method) {
      Severity: Minor
      Found in src/NotificationTrait.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 shouldReceiveNotification has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function shouldReceiveNotification(NotificationInterface $notification)
          {
              $alias = Inflector::camel2id(get_class($notification));
              if (isset($this->notificationSettings)) {
                  $settings = $this->notificationSettings;
      Severity: Minor
      Found in src/NotifiableTrait.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