assemblee-virtuelle/wp-ldp

View on GitHub

Showing 378 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

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

                $labels = array(
                    'name'                       => __( 'Sites', 'wpldp' ),
                    'singular_name'              => __( 'Site', 'wpldp' ),
                    'menu_name'                  => __( 'Sites', 'wpldp' ),
                    'all_items'                  => __( 'All Items', 'wpldp' ),
    Severity: Major
    Found in class-site-taxonomy.php and 1 other location - About 1 day to fix
    class-container-taxonomy.php on lines 70..88

    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 263.

    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

                $labels = array(
                    'name'                       => __( 'Containers', 'wpldp' ),
                    'singular_name'              => __( 'Container', 'wpldp' ),
                    'menu_name'                  => __( 'Containers', 'wpldp' ),
                    'all_items'                  => __( 'All Items', 'wpldp' ),
    Severity: Major
    Found in class-container-taxonomy.php and 1 other location - About 1 day to fix
    class-site-taxonomy.php on lines 71..89

    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 263.

    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

    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

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

              public function __construct() {
                  register_activation_hook( __FILE__, array( $this, 'wpldp_rewrite_flush' ) );
                  add_action( 'init', array( $this, 'register_site_taxonomy' ), 0 );
      
                  add_action( 'ldp_site_add_form_fields', array( $this, 'add_custom_tax_fields_oncreate_site' ) );
      Severity: Major
      Found in class-site-taxonomy.php and 1 other location - About 6 hrs to fix
      class-container-taxonomy.php on lines 31..51

      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 218.

      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 __construct() {
                  register_activation_hook( __FILE__, array( $this, 'wpldp_rewrite_flush' ) );
                  add_action( 'init', array( $this, 'register_container_taxonomy' ), 0 );
      
                  add_action( 'ldp_container_add_form_fields', array( $this, 'add_custom_tax_fields_oncreate' ) );
      Severity: Major
      Found in class-container-taxonomy.php and 1 other location - About 6 hrs to fix
      class-site-taxonomy.php on lines 31..52

      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 218.

      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 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
                    Severity
                    Category
                    Status
                    Source
                    Language