awsmug/torro-forms

View on GitHub
src/modules/access-controls/user-identification.php

Summary

Maintainability
D
2 days
Test Coverage

Function can_access has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

    public function can_access( $form, $submission = null ) {
        if ( $this->get_form_option( $form->id, 'prevent_edit_others_submission', true ) && $submission ) {
            $others_submission_error = new WP_Error( 'others_submission', __( 'You do not have access to this form submission.', 'torro-forms' ) );
            
            $skip_further_checks = false;
Severity: Minor
Found in src/modules/access-controls/user-identification.php - About 1 day 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 can_access has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function can_access( $form, $submission = null ) {
        if ( $this->get_form_option( $form->id, 'prevent_edit_others_submission', true ) && $submission ) {
            $others_submission_error = new WP_Error( 'others_submission', __( 'You do not have access to this form submission.', 'torro-forms' ) );
            
            $skip_further_checks = false;
Severity: Major
Found in src/modules/access-controls/user-identification.php - About 3 hrs to fix

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

        public function get_meta_fields() {
            $meta_fields = parent::get_meta_fields();
    
            unset( $meta_fields['enabled'] );
    
    
    Severity: Minor
    Found in src/modules/access-controls/user-identification.php - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

              return true;
      Severity: Major
      Found in src/modules/access-controls/user-identification.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return new WP_Error( 'already_submitted', $message );
        Severity: Major
        Found in src/modules/access-controls/user-identification.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return true;
          Severity: Major
          Found in src/modules/access-controls/user-identification.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return new WP_Error( 'already_submitted', $message );
            Severity: Major
            Found in src/modules/access-controls/user-identification.php - About 30 mins to fix

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

                  public function set_submission_data( $submission, $form, $data ) {
                      $identification_modes = $this->get_form_option( $form->id, 'identification_modes', array() );
              
                      if ( in_array( 'ip_address', $identification_modes, true ) ) {
                          $validated_ip = Fixes::php_filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP );
              Severity: Minor
              Found in src/modules/access-controls/user-identification.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

              There are no issues that match your filters.

              Category
              Status