awsmug/torro-forms

View on GitHub

Showing 503 of 503 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function __construct( $prefix, $services, $translations ) {
        $this->class_name                 = Element_Choice::class;
        $this->collection_class_name      = Element_Choice_Collection::class;
        $this->query_class_name           = Element_Choice_Query::class;
        $this->rest_controller_class_name = REST_Element_Choices_Controller::class;
Severity: Major
Found in src/db-objects/element-choices/element-choice-manager.php and 1 other location - About 7 hrs to fix
src/db-objects/containers/container-manager.php on lines 52..75

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 226.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method upgrade_legacy_form_meta has 169 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function upgrade_legacy_form_meta( $form_id ) {
        global $wpdb;

        $prefix = $this->get_prefix();

Severity: Major
Found in src/components/legacy-upgrades.php - About 6 hrs to fix

    Function map_capabilities has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        public function map_capabilities( $mode ) {
            $this->capability_mappings = array();
    
            if ( $mode ) {
                $this->capability_mappings[ $this->meta_capabilities['edit_item'] ]   = array( $this, 'map_edit_item' );
    Severity: Minor
    Found in src/db-objects/form-categories/form-category-capabilities.php - About 6 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

    File members.php has 446 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Members access control class
     *
     * @package TorroForms
    Severity: Minor
    Found in src/modules/access-controls/members.php - About 6 hrs to fix

      File email-notifications.php has 443 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Email notifications action class
       *
       * @package TorroForms
      Severity: Minor
      Found in src/modules/actions/email-notifications.php - About 6 hrs to fix

        Method register_template_tag_handlers has 161 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function register_template_tag_handlers() {
                $tags = array(
                    'sitetitle'          => array(
                        'group'       => 'global',
                        'label'       => __( 'Site Title', 'torro-forms' ),
        Severity: Major
        Found in src/modules/actions/email-notifications.php - About 6 hrs to fix

          Method setup_hooks has 159 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function setup_hooks() {
                  parent::setup_hooks();
          
                  if ( method_exists( $this, 'register_rest_routes' ) ) {
                      $this->filters[] = array(
          Severity: Major
          Found in src/db-objects/forms/form-manager.php - About 6 hrs to fix

            File torro-forms.php has 419 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Plugin main class
             *
             * @package TorroForms
            Severity: Minor
            Found in src/torro-forms.php - About 6 hrs to fix

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  public function validate_field( $value, $element, $submission ) {
                      $settings = $this->get_settings( $element );
                      $choices  = $this->get_choices_for_field( $element );
              
                      $value = trim( (string) $value );
              Severity: Major
              Found in src/db-objects/elements/element-types/base/dropdown.php and 1 other location - About 5 hrs to fix
              src/db-objects/elements/element-types/base/onechoice.php on lines 84..99

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 198.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  public function validate_field( $value, $element, $submission ) {
                      $settings = $this->get_settings( $element );
                      $choices  = $this->get_choices_for_field( $element );
              
                      $value = trim( (string) $value );
              Severity: Major
              Found in src/db-objects/elements/element-types/base/onechoice.php and 1 other location - About 5 hrs to fix
              src/db-objects/elements/element-types/base/dropdown.php on lines 75..90

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 198.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function upgrade_legacy_settings has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function upgrade_legacy_settings() {
                      $prefix = $this->get_prefix();
              
                      $general_mappings = array(
                          'modules'        => array( $prefix . 'settings_general_modules', 'modules' ),
              Severity: Minor
              Found in src/components/legacy-upgrades.php - About 5 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 get_item_schema has 138 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function get_item_schema() {
                      $schema = array(
                          '$schema'    => 'http://json-schema.org/schema#',
                          'title'      => $this->manager->get_singular_slug() . '_type',
                          'type'       => 'object',

                File submission.php has 394 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Submission class
                 *
                 * @package TorroForms
                Severity: Minor
                Found in src/db-objects/submissions/submission.php - About 5 hrs to fix

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

                      public function validate_field( $value, $element, $submission ) {
                          $settings = $this->get_settings( $element );
                  
                          $value = absint( $value );
                  
                  
                  Severity: Minor
                  Found in src/db-objects/elements/element-types/base/media.php - About 5 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 get_fields has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function get_fields() {
                          $fields = array(
                              'form_id'     => array(
                                  'section'      => 'associated_data',
                                  'type'         => 'autocomplete',
                  Severity: Minor
                  Found in src/db-objects/submissions/submission-edit-page.php - About 5 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 print_templates has 134 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function print_templates() {
                          ?>
                          <script type="text/html" id="tmpl-torro-failure">
                              <div class="torro-notice notice-error">
                                  <p>
                  Severity: Major
                  Found in src/db-objects/forms/form-edit-page-handler.php - About 5 hrs to fix

                    Method handle_form_submission has 130 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function handle_form_submission( $form, $submission, $data = array() ) {
                            if ( $submission->has_errors() ) {
                                $submission->reset_errors();
                            }
                    
                    
                    Severity: Major
                    Found in src/db-objects/forms/form-frontend-submission-handler.php - About 5 hrs to fix

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          public function get_item_schema() {
                              $schema = parent::get_item_schema();
                      
                              $schema['properties']['element_id'] = array(
                                  'description' => __( 'ID of the element this element choice belongs to.', 'torro-forms' ),
                      src/db-objects/element-settings/rest-element-settings-controller.php on lines 40..66

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 187.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          public function get_item_schema() {
                              $schema = parent::get_item_schema();
                      
                              $schema['properties']['element_id'] = array(
                                  'description' => __( 'ID of the element this element setting belongs to.', 'torro-forms' ),
                      src/db-objects/element-choices/rest-element-choices-controller.php on lines 40..66

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 187.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Method register_template_tag_handlers has 127 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function register_template_tag_handlers() {
                              $tags = array(
                                  'sitetitle'       => array(
                                      'group'       => 'global',
                                      'label'       => __( 'Site Title', 'torro-forms' ),
                      Severity: Major
                      Found in src/modules/access-controls/members.php - About 5 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language