awsmug/torro-forms-plugin-boilerplate

View on GitHub

Showing 11 of 34 total issues

Function filter_json has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function filter_json( $data, $element, $submission = null ) {
        $data = parent::filter_json( $data, $element, $submission );

        $settings = $this->get_settings( $element );

Severity: Minor
Found in src/element-types/autocomplete.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 filter_json has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function filter_json( $data, $element, $submission = null ) {
        $data = parent::filter_json( $data, $element, $submission );

        $settings = $this->get_settings( $element );

Severity: Minor
Found in src/element-types/autocomplete.php - About 1 hr to fix

    Function source has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                source: function( request, response ) {
                    var restUrl = scriptData.restUrl + searchRoute.replace( '%search%', request.term );
    
                    $.ajax( restUrl, {
                        method:   'GET',
    Severity: Minor
    Found in assets/dist/js/autocomplete-element.js - About 1 hr to fix

      Method filter_json has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function filter_json( $data, $element, $submission = null ) {
              global $wp_locale;
      
              $data = parent::filter_json( $data, $element, $submission );
      
      
      Severity: Minor
      Found in src/element-types/date.php - About 1 hr to fix

        Function source has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    source: function( request, response ) {
                        var restUrl = scriptData.restUrl + searchRoute.replace( '%search%', request.term );
        
                        $.ajax( restUrl, {
                            method:   'GET',
        Severity: Minor
        Found in assets/src/js/autocomplete-element.js - About 1 hr to fix

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

              public function validate_field( $value, $element, $submission ) {
                  $settings = $this->get_settings( $element );
          
                  // Support Y-m-d string passed, just so that submission editing with single field works too.
                  if ( is_string( $value ) && 2 === substr_count( $value, '-' ) ) {
          Severity: Minor
          Found in src/element-types/date.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

          Avoid deeply nested control flow statements.
          Open

                                  if ( ! isset( $item->$property ) ) {
                                      $not_found = true;
                                      break;
                                  }
          Severity: Major
          Found in src/element-types/autocomplete.php - About 45 mins to fix

            Method process_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                protected function process_response( $response, $connection, $route_slug, $submission, $form ) {
            Severity: Minor
            Found in src/actions/frontend-posting.php - About 35 mins to fix

              Function validate_field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function validate_field( $value, $element, $submission ) {
                      $settings = $this->get_settings( $element );
              
                      $value = (int) trim( $value );
              
              
              Severity: Minor
              Found in src/element-types/autocomplete.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 $parsed_value;
              Severity: Major
              Found in src/element-types/date.php - About 30 mins to fix

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

                    protected function detect_date_fields_order() {
                        $date_format = get_option( 'date_format' );
                        $date_format = str_split( $date_format );
                
                        $year_group  = array( 'Y', 'y' );
                Severity: Minor
                Found in src/element-types/date.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