assemblee-virtuelle/wp-ldp

View on GitHub

Showing 45 of 379 total issues

Function save_ldp_meta_for_post has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
Open

        public function save_ldp_meta_for_post( $resource_id ) {
            $fields = Utils::get_resource_fields_list( $resource_id );

            if ( ! empty( $fields ) ) {
                foreach ( $_POST as $key => $value ) {
Severity: Minor
Found in wp-ldp.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

Function wpldp has 271 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.wpldp = function( store, options ) {

    this.options = options || {};
    this.store   = store;
    this.resultSet = [];
Severity: Major
Found in wpldp.js - About 1 day to fix

    Function get_resource has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

            public function get_resource( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
                $params = $request->get_params();
                $ldp_container = $params['ldp_container'];
                $ldp_resource_slug = $params['ldp_resource'];
    
    
    Severity: Minor
    Found in class-api.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

    File wp-ldp.php has 500 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * The WP-LDP Plugin main file
     * @package     WPLDP
     * @author      Benoit Alessandroni
    Severity: Minor
    Found in wp-ldp.php - About 1 day to fix

      Function wpldp_plugin_update has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

              function wpldp_plugin_update() {
                  $plugin_version = get_option( 'wpldp_version' );
                  $update_option = null;
      
                  if ( self::$version_number !== $plugin_version ) {
      Severity: Minor
      Found in wp-ldp.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 initialize_container has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

              function initialize_container( $force = false ) {
                  if ( isset( $_GET['settings-updated'] ) || $force ) {
                      $ldp_container_init = get_option( 'ldp_container_init', false );
      
                      if ( $ldp_container_init || $force ) {
      Severity: Minor
      Found in class-settings.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

      Method initialize_container has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function initialize_container( $force = false ) {
                  if ( isset( $_GET['settings-updated'] ) || $force ) {
                      $ldp_container_init = get_option( 'ldp_container_init', false );
      
                      if ( $ldp_container_init || $force ) {
      Severity: Major
      Found in class-settings.php - About 3 hrs to fix

        Method get_resource has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function get_resource( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
                    $params = $request->get_params();
                    $ldp_container = $params['ldp_container'];
                    $ldp_resource_slug = $params['ldp_resource'];
        
        
        Severity: Major
        Found in class-api.php - About 3 hrs to fix

          Function get_api_definition has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function get_api_definition( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
                      header( 'Content-Type: application/ld+json' );
                      header( 'Access-Control-Allow-Origin: *' );
          
                      $query = new \WP_Query(
          Severity: Minor
          Found in class-api.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

          Function get_sites_list has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function get_sites_list( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
                      header( 'Content-Type: application/ld+json' );
                      header( 'Access-Control-Allow-Origin: *' );
          
                      $terms = get_terms(
          Severity: Minor
          Found in class-site-taxonomy.php - About 2 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 wpldp.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          window.wpldp = function( store, options ) {
          
              this.options = options || {};
              this.store   = store;
              this.resultSet = [];
          Severity: Minor
          Found in wpldp.js - About 2 hrs to fix

            Function format_posts_rendering has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                    private function format_posts_rendering( $result, $posts ) {
                        $count = 0;
                        foreach ( $posts as $post ) {
                            $values = get_the_terms( $post->ID, 'ldp_container' );
                            if ( empty( $values[0] ) ) {
            Severity: Minor
            Found in class-container-taxonomy.php - About 2 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

            WpLdp has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

                class WpLdp {
            
                    /**
                     * The front page url, defaulted as 'wp-ldp/front'.
                     */
            Severity: Minor
            Found in wp-ldp.php - About 2 hrs to fix

              File class-container-taxonomy.php has 256 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * Container
               *
               * The container taxonomy class and instance.
              Severity: Minor
              Found in class-container-taxonomy.php - About 2 hrs to fix

                Method save_ldp_meta_for_post has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        public function save_ldp_meta_for_post( $resource_id ) {
                            $fields = Utils::get_resource_fields_list( $resource_id );
                
                            if ( ! empty( $fields ) ) {
                                foreach ( $_POST as $key => $value ) {
                Severity: Major
                Found in wp-ldp.php - About 2 hrs to fix

                  Method wpldp_plugin_update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function wpldp_plugin_update() {
                              $plugin_version = get_option( 'wpldp_version' );
                              $update_option = null;
                  
                              if ( self::$version_number !== $plugin_version ) {
                  Severity: Minor
                  Found in wp-ldp.php - About 2 hrs to fix

                    Function render has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        this.render = function render( div, objectIri, template, context, modelName, prefix ) {
                            var objectIri = this.store.getIri(objectIri);
                            var template = template ? template : this.store.mainTemplate;
                            var context = context || this.store.context;
                            var fields = modelName ? this.store.models[modelName].fields : null;
                    Severity: Minor
                    Found in wpldp.js - About 1 hr to fix

                      Method get_sites_list has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              public function get_sites_list( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
                                  header( 'Content-Type: application/ld+json' );
                                  header( 'Access-Control-Allow-Origin: *' );
                      
                                  $terms = get_terms(
                      Severity: Minor
                      Found in class-site-taxonomy.php - About 1 hr to fix

                        Method get_api_definition has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                public function get_api_definition( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
                                    header( 'Content-Type: application/ld+json' );
                                    header( 'Access-Control-Allow-Origin: *' );
                        
                                    $query = new \WP_Query(
                        Severity: Minor
                        Found in class-api.php - About 1 hr to fix

                          Method ldp_enqueue_script has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  public function ldp_enqueue_script() {
                                      global $pagenow, $post_type;
                                      $screen = get_current_screen();
                                      if ( Wpldp::RESOURCE_POST_TYPE === $post_type ) {
                                          wp_enqueue_media();
                          Severity: Minor
                          Found in wp-ldp.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language