BZCoding/bz-contact-php

View on GitHub

Showing 12 of 617 total issues

Function field has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    public function field($id)
    {
        if (!empty($this->form->fields[$id])) {
            $field = $this->form->fields[$id];

Severity: Minor
Found in app/lib/BZContact/Form/FormBuilder.php - About 4 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

Function __construct has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($data)
    {

        // Try to parse JSON
        if (($form = json_decode($data)) === null) {
Severity: Minor
Found in app/lib/BZContact/Form/FormBuilder.php - About 3 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 __construct has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($data)
    {

        // Try to parse JSON
        if (($form = json_decode($data)) === null) {
Severity: Minor
Found in app/lib/BZContact/Form/FormBuilder.php - About 1 hr to fix

    Method field has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function field($id)
        {
            if (!empty($this->form->fields[$id])) {
                $field = $this->form->fields[$id];
    
    
    Severity: Minor
    Found in app/lib/BZContact/Form/FormBuilder.php - About 1 hr to fix

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

          public function open()
          {
              $open = new Elements\FormOpen;
      
              if ($this->hasToken()) {
      Severity: Minor
      Found in app/lib/BZContact/Form/FormBuilder.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 buildRules has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          private function buildRules()
          {
              $rules = [];
              foreach ($this->fields as $field) {
                  //  Add rule for required fields
      Severity: Minor
      Found in app/lib/BZContact/Form/Form.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

      Method buildRules has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function buildRules()
          {
              $rules = [];
              foreach ($this->fields as $field) {
                  //  Add rule for required fields
      Severity: Minor
      Found in app/lib/BZContact/Form/Form.php - About 1 hr to fix

        Method open has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function open()
            {
                $open = new Elements\FormOpen;
        
                if ($this->hasToken()) {
        Severity: Minor
        Found in app/lib/BZContact/Form/FormBuilder.php - About 1 hr to fix

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

              public function parseSelectOptions($options = null)
              {
                  if (!empty($options && is_array($options))) {
                      $selectOptions = [];
                      foreach ($options as $option) {
          Severity: Minor
          Found in app/lib/BZContact/Form/Form.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 filter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function filter(array $data)
              {
                  $filteredData = [];
                  foreach ($data as $key => $value) {
                      if (array_key_exists($key, $this->names)) {
          Severity: Minor
          Found in app/lib/BZContact/Form/Form.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 forId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function forId($name)
              {
                  parent::forId($name);
                  if (!empty($this->form->fields[$name])) {
                      $this->setAttribute('for', $this->form->fields[$name]->id);
          Severity: Minor
          Found in app/lib/BZContact/Form/Elements/Label.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 buildRules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private function buildRules()
              {
                  foreach ($this->rules as $ruleName => $ruleData) {
                      foreach ($ruleData as $ruleDataItem) {
                          $params = (!empty($ruleDataItem['params'])) ? $ruleDataItem['params'] : null;
          Severity: Minor
          Found in app/lib/BZContact/Form/Validator.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