alerts/class-alert-type-slack.php

Summary

Maintainability
C
1 day
Test Coverage
F
8%

Method alert has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function alert( $record_id, $recordarr, $alert ) {
        $options = wp_parse_args(
            $alert->alert_meta,
            array(
                'webhook'           => '',
Severity: Major
Found in alerts/class-alert-type-slack.php - About 4 hrs to fix

    Method display_fields has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function display_fields( $alert ) {
            $alert_meta = array();
            if ( is_object( $alert ) ) {
                $alert_meta = $alert->alert_meta;
            }
    Severity: Major
    Found in alerts/class-alert-type-slack.php - About 2 hrs to fix

      Function alert has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function alert( $record_id, $recordarr, $alert ) {
              $options = wp_parse_args(
                  $alert->alert_meta,
                  array(
                      'webhook'           => '',
      Severity: Minor
      Found in alerts/class-alert-type-slack.php - About 1 hr 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 add_alert_meta has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function add_alert_meta( $alert_meta, $alert_type ) {
              if ( $this->slug === $alert_type ) {
                  $webhook = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_webhook' );
                  if ( ! empty( $webhook ) ) {
                      $alert_meta['webhook'] = $webhook;
      Severity: Minor
      Found in alerts/class-alert-type-slack.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

      There are no issues that match your filters.

      Category
      Status