presscodes/maera

View on GitHub

Showing 43 of 43 total issues

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

$cache_modes = array(
    array( 'value' => 'none',      'label' => esc_html__( 'No Caching', 'maera' ) ),
    array( 'value' => 'object',    'label' => esc_html__( 'WP Object Caching', 'maera' ) ),
    array( 'value' => 'transient', 'label' => esc_html__( 'Transients', 'maera' ) ),
    array( 'value' => 'default',   'label' => esc_html__( 'Default', 'maera' ) ),
Severity: Major
Found in includes/admin/tabs/settings.php and 1 other location - About 1 hr to fix
includes/class-maera-admin.php on lines 181..186

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

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

    function colorposts_build_css( $styles ) {

        $src = $this->custom_header_url();

        if ( $src && get_template_directory_uri() . '/core-shell/assets/images/grid-back.png' != $src ) {
Severity: Minor
Found in core-shell/class-Maera_Shell_Core.php - About 1 hr to fix

    Method grab_points has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function grab_points( $type = 'index' ) {
            $img = $this->image_obj;
            if ( ! $img )
                return false;
    
    
    Severity: Minor
    Found in includes/class-tonesque.php - About 1 hr to fix

      Method add_settings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function add_settings( $wp_customize ) {
      
              $wp_customize->add_setting( 'maera_admin_options[shell]', array(
                  'default'        => 'core',
                  'type'           => 'option',
      Severity: Minor
      Found in includes/class-maera-core-customizer.php - About 1 hr to fix

        Method get_context has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_context() {
        
                global $content_width;
        
                if ( class_exists( 'Easy_Digital_Downloads' ) ) {
        Severity: Minor
        Found in includes/class-maera-timber.php - About 1 hr to fix

          Method purchase_variable_pricing has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function purchase_variable_pricing( $download_id ) {
          
                  $variable_pricing = edd_has_variable_prices( $download_id );
          
                  if ( ! $variable_pricing ) {
          Severity: Minor
          Found in includes/class-maera-edd-mods.php - About 1 hr to fix

            Function form has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                function form( $instance ) {
            
                    $defaults = array(
                        'title'           => 'Latest Articles',
                        'post_type'       => 'post',

            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 colorposts_build_css has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                function colorposts_build_css( $styles ) {
            
                    $src = $this->custom_header_url();
            
                    if ( $src && get_template_directory_uri() . '/core-shell/assets/images/grid-back.png' != $src ) {
            Severity: Minor
            Found in core-shell/class-Maera_Shell_Core.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

            Method context has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function context() {
            
                    global $wp_query;
            
                    $context = Maera()->cache->get_context();
            Severity: Minor
            Found in includes/class-maera-template.php - About 1 hr to fix

              Function colors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  function colors() {
              
                      $thumb_id  = get_post_thumbnail_id( $this->post_id );
                      $thumb_url = wp_get_attachment_image_src( $thumb_id );
                      $thumb_url = $thumb_url[0];
              Severity: Minor
              Found in includes/class-maera-edd-tonesque.php - About 55 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

              Function cache_mode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function cache_mode() {
              
                      $options    = get_option( 'maera_admin_options', array() );
                      $cache_mode = isset( $options['cache_mode'] ) ? $options['cache_mode'] : 'default';
              
              
              Severity: Minor
              Found in includes/class-maera-caching.php - About 55 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

              Function widget_areas has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      function widget_areas() {
              
                          $areas = $this->extra_widget_areas_array();
              
                          $class        = apply_filters( 'maera/widgets/class', '' );
              Severity: Minor
              Found in includes/class-maera-cwa.php - About 55 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

              Function admin_page has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  function admin_page() {
              
                      global $pagenow;
              
                      $tabs    = $this->tabs();
              Severity: Minor
              Found in includes/class-maera-admin.php - About 45 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

              Function context has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function context() {
              
                      global $wp_query;
              
                      $context = Maera()->cache->get_context();
              Severity: Minor
              Found in includes/class-maera-template.php - About 45 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

              Function validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  function validate( $settings ) {
              
                      // Import the imported options
                      if ( isset( $settings['import_data'] ) && ! empty( $settings['import_data'] ) ) {
              
              
              Severity: Minor
              Found in includes/class-maera-admin.php - About 45 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

              Consider simplifying this complex logical expression.
              Open

                      if (isset($params[2])
                          && !is_int($params[2])
                          && !is_float($params[2])
                          && !is_string($params[2])
                          && !(is_object($params[2]) && method_exists($params[2], '__toString'))
              Severity: Major
              Found in includes/utils.php - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if (!is_int($params[1])
                            && !is_float($params[1])
                            && !is_string($params[1])
                            && $params[1] !== null
                            && !(is_object($params[1]) && method_exists($params[1], '__toString'))
                Severity: Major
                Found in includes/utils.php - About 40 mins to fix

                  Function extra_widget_areas_wrapper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                          function extra_widget_areas_wrapper( $area = null, $class = '' ) {
                  
                              // Do not proceed if we have not specified an area
                              if ( is_null( $area ) ) {
                                  return;
                  Severity: Minor
                  Found in includes/class-maera-cwa.php - About 35 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

                  Avoid too many return statements within this method.
                  Open

                          return $resultArray;
                  Severity: Major
                  Found in includes/utils.php - About 30 mins to fix

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

                        function custom_css_cached() {
                    
                            if ( Maera()->dev->dev_mode() ) {
                                // Get our styles using the maera/styles filter
                                $data = apply_filters( 'maera/styles', null );
                    Severity: Minor
                    Found in includes/class-maera-caching.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

                    Severity
                    Category
                    Status
                    Source
                    Language