assemblee-virtuelle/wp-ldp

View on GitHub
class-settings.php

Summary

Maintainability
C
1 day
Test Coverage

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 menu_setup has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function menu_setup() {
                global $submenu;
                // Removing all resources menu.
                remove_submenu_page( 'edit.php?post_type=ldp_resource', 'edit.php?post_type=ldp_resource' );
                $terms = get_terms(
    Severity: Minor
    Found in class-settings.php - About 1 hr to fix

      Function menu_setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              function menu_setup() {
                  global $submenu;
                  // Removing all resources menu.
                  remove_submenu_page( 'edit.php?post_type=ldp_resource', 'edit.php?post_type=ldp_resource' );
                  $terms = get_terms(
      Severity: Minor
      Found in class-settings.php - About 1 hr 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_validation_notice has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              function wpldp_validation_notice() {
                  global $pagenow;
                  if ( 'options-general.php' === $pagenow && 'wpldp' === $_GET['page'] ) { // change my-plugin to your plugin page.
                      if ( ( isset( $_GET['settings-updated'] ) && 'true' === $_GET['settings-updated'] ) ) {
      
      
      Severity: Minor
      Found in class-settings.php - About 1 hr 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

      Visibility must be declared on method "initialize_container"
      Open

              function initialize_container( $force = false ) {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Organization', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Overriding WordPress globals is prohibited. Found assignment to $submenu
      Open

                              $submenu['edit.php?post_type=ldp_resource'][ 10 - $i ] = $submenu_item_value;
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
      Open

                              $model = file_get_contents( __DIR__ . '/models/' . $term . '.json' );
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
      Open

                                  $updated_term = wp_update_term(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 8 space(s) between "'slug'" and double arrow, but found 1.
      Open

                                          'slug' => $term,
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 8 space(s) between "'slug'" and double arrow, but found 1.
      Open

                                          'slug' => $term,
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
      Open

                                              __(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Document', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Processing form data without nonce verification.
      Open

                      if ( ( isset( $_GET['settings-updated'] ) && 'true' === $_GET['settings-updated'] ) ) {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 8 space(s) between "'person'" and double arrow, but found 1.
      Open

                              'person' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'get_option'.
      Open

                  echo "<input type='text' size='150' name='ldp_context' value='" . get_option( 'ldp_context', 'http://lov.okfn.org/dataset/lov/context' ) . "' />";
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Visibility must be declared on method "menu_setup"
      Open

              function menu_setup() {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Visibility must be declared on method "backend_hooking"
      Open

              function backend_hooking() {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Visibility must be declared on method "ldp_container_init_field"
      Open

              function ldp_container_init_field() {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 8 space(s) between "'thesis'" and double arrow, but found 1.
      Open

                              'thesis' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Processing form data without nonce verification.
      Open

                  if ( isset( $_GET['settings-updated'] ) || $force ) {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Initiative', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Processing form data without nonce verification.
      Open

                      if ( ( isset( $_GET['settings-updated'] ) && 'true' === $_GET['settings-updated'] ) ) {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Visibility must be declared on method "wpldp_options_page"
      Open

              function wpldp_options_page() {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 2 space(s) between "'organization'" and double arrow, but found 1.
      Open

                              'organization' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
      Open

                                              __(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Place', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 9 space(s) between "'theme'" and double arrow, but found 1.
      Open

                              'theme' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Processing form data without nonce verification.
      Open

                  if ( 'options-general.php' === $pagenow && 'wpldp' === $_GET['page'] ) { // change my-plugin to your plugin page.
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 4 space(s) between "'initiative'" and double arrow, but found 1.
      Open

                              'initiative' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
      Open

                                  $term_meta['ldp_model'] = stripslashes_deep( $model );
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'.
      Open

                  echo '<h2>' . __( 'WP-LDP Settings', 'wpldp' ) . '</h2>';
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 9 space(s) between "'group'" and double arrow, but found 1.
      Open

                              'group' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 6 space(s) between "'document'" and double arrow, but found 1.
      Open

                              'document' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Theme', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Visibility must be declared on method "ldp_menu"
      Open

              function ldp_menu() {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Group', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 7 space(s) between "'artwork'" and double arrow, but found 1.
      Open

                              'artwork' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Event', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 6 space(s) between "'order'" and double arrow, but found 1.
      Open

                          'order' => 'DESC'
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Each array item in a multi-line array declaration must end in a comma
      Open

                          'order' => 'DESC'
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 9 space(s) between "'event'" and double arrow, but found 1.
      Open

                              'event' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Each array item in a multi-line array declaration must end in a comma
      Open

                              )
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Visibility must be declared on method "ldp_context_field"
      Open

              function ldp_context_field() {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Good or Service', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 9 space(s) between "'place'" and double arrow, but found 1.
      Open

                              'place' => array(
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Thesis', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Artwork', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead.
      Open

                              $model = file_get_contents( __DIR__ . '/models/' . $term . '.json' );
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'label'" and double arrow, but found 1.
      Open

                                  'label' => __( 'Person', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Detected usage of a non-validated input variable: $_GET
      Open

                  if ( 'options-general.php' === $pagenow && 'wpldp' === $_GET['page'] ) { // change my-plugin to your plugin page.
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      Visibility must be declared on method "wpldp_validation_notice"
      Open

              function wpldp_validation_notice() {
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
      Open

                              __( 'List of all resources of type %1$s', 'wpldp' ),
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'.
      Open

                          echo __( 'The generals settings of the WP-LDP plugin.', 'wpldp' );
      Severity: Minor
      Found in class-settings.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status