wp-plugins/all-in-one-seo-pack

View on GitHub
aioseop_opengraph.php

Summary

Maintainability
F
1 wk
Test Coverage

Function add_meta has a Cognitive Complexity of 229 (exceeds 5 allowed). Consider refactoring.
Open

        function add_meta( ) {
            global $post, $aiosp, $aioseop_options, $wp_query;
            $metabox = $this->get_current_options( Array(), 'settings' );
            $key = $this->options['aiosp_opengraph_key'];
            $dimg = $this->options['aiosp_opengraph_dimg'];
Severity: Minor
Found in aioseop_opengraph.php - About 4 days 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 aioseop_opengraph.php has 802 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @package All-in-One-SEO-Pack
 */
/**
Severity: Major
Found in aioseop_opengraph.php - About 1 day to fix

    Method All_in_One_SEO_Pack_Opengraph has 284 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function All_in_One_SEO_Pack_Opengraph( ) {
                $this->name = __('Social Meta', 'all-in-one-seo-pack');    // Human-readable name of the plugin
                $this->prefix = 'aiosp_opengraph_';                        // option prefix
                $this->file = __FILE__;                                    // the current file
                $this->fb_object_types = Array(
    Severity: Major
    Found in aioseop_opengraph.php - About 1 day to fix

      Method add_meta has 265 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function add_meta( ) {
                  global $post, $aiosp, $aioseop_options, $wp_query;
                  $metabox = $this->get_current_options( Array(), 'settings' );
                  $key = $this->options['aiosp_opengraph_key'];
                  $dimg = $this->options['aiosp_opengraph_dimg'];
      Severity: Major
      Found in aioseop_opengraph.php - About 1 day to fix

        Function filter_settings has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

                function filter_settings( $settings, $location, $current ) {
                    if ( $location == 'opengraph' || $location == 'settings' ) {
                        $prefix = $this->get_prefix( $location ) . $location . '_';
                        if ( $location == 'opengraph' ) return $settings;
                        if ( $location == 'settings'  ) {
        Severity: Minor
        Found in aioseop_opengraph.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

        Function filter_options has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

                function filter_options( $options, $location ) {
                    if ( $location == 'settings' ) {
                        $prefix = $this->get_prefix( $location ) . $location . '_';
                        list( $legacy, $images ) = $this->get_all_images( $options );
                        if ( isset( $options ) && isset( $options["{$prefix}image"] ) ) {
        Severity: Minor
        Found in aioseop_opengraph.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 get_all_images has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

                function get_all_images( $options = null, $p = null ) {
                    static $img = Array();
                    if ( !is_array( $options ) ) $options = Array();
                    if ( !empty( $this->options['aiosp_opengraph_meta_key'] ) )
                        $options['meta_key'] = $this->options['aiosp_opengraph_meta_key'];
        Severity: Minor
        Found in aioseop_opengraph.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

        Function settings_page_init has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

                function settings_page_init() {
                    add_filter( 'aiosp_output_option', Array( $this, 'display_custom_options' ), 10, 2 );
                    $cat = $this->options["{$this->prefix}categories"];
                    if ( !empty( $cat ) ) {
                        if ( $cat == 'blog' ) {
        Severity: Minor
        Found in aioseop_opengraph.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 filter_settings has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function filter_settings( $settings, $location, $current ) {
                    if ( $location == 'opengraph' || $location == 'settings' ) {
                        $prefix = $this->get_prefix( $location ) . $location . '_';
                        if ( $location == 'opengraph' ) return $settings;
                        if ( $location == 'settings'  ) {
        Severity: Minor
        Found in aioseop_opengraph.php - About 1 hr to fix

          Method add_attributes has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  function add_attributes( $output ) { // avoid having duplicate meta tags
                      $type = $this->type;
                      if ( empty( $type ) ) $type = 'website';
                      
                      $schema_types = Array(
          Severity: Minor
          Found in aioseop_opengraph.php - About 1 hr to fix

            Function type_setup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                    function type_setup() {
                        global $aiosp, $wp_query;
                        $this->type = '';
                        if ( $aiosp->is_static_front_page() ) {
                            if ( !empty( $this->options ) && !empty( $this->options['aiosp_opengraph_categories'] ) )
            Severity: Minor
            Found in aioseop_opengraph.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 All_in_One_SEO_Pack_Opengraph has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    function All_in_One_SEO_Pack_Opengraph( ) {
                        $this->name = __('Social Meta', 'all-in-one-seo-pack');    // Human-readable name of the plugin
                        $this->prefix = 'aiosp_opengraph_';                        // option prefix
                        $this->file = __FILE__;                                    // the current file
                        $this->fb_object_types = Array(
            Severity: Minor
            Found in aioseop_opengraph.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 add_attributes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    function add_attributes( $output ) { // avoid having duplicate meta tags
                        $type = $this->type;
                        if ( empty( $type ) ) $type = 'website';
                        
                        $schema_types = Array(
            Severity: Minor
            Found in aioseop_opengraph.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 override_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    function override_options( $options, $location, $settings ) {
                        $opts = Array();
                        foreach ( $settings as $k => $v ) if ( $v['save'] ) $opts[$k] = $v['default'];
                        foreach( $options as $k => $v ) if ( $v === NULL ) unset( $options[$k] );
                        $options = wp_parse_args( $options, $opts );
            Severity: Minor
            Found in aioseop_opengraph.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 filter_metabox_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    function filter_metabox_options( $options, $location, $post_id ) {
                        if ( $location == 'settings' ) {
                            $prefix = $this->get_prefix( $location ) . $location;
                            if ( !empty( $options[$prefix . '_customimg'] ) ) {
                                $old_options = get_post_meta( $post_id, '_' . $prefix );
            Severity: Minor
            Found in aioseop_opengraph.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 get_the_image_by_author has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    function get_the_image_by_author( $options = null, $p = null ) {
                        if ( $p === null ) {
                            global $post;
                        } else {
                            $post = $p;
            Severity: Minor
            Found in aioseop_opengraph.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

            Avoid deeply nested control flow statements.
            Open

                                        if ( !empty( $legacy[$thumbnail] ) )
                                            $thumbnail = $legacy[$thumbnail];
            Severity: Major
            Found in aioseop_opengraph.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ( !empty( $keywords ) && !empty( $tag ) ) {
                                          $tag .= ',' . $keywords;
                                      } elseif ( empty( $tag ) ) {
                                          $tag = $keywords;
                                      }
              Severity: Major
              Found in aioseop_opengraph.php - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                                if ( empty( $description ) && $first_page && ( !empty( $this->options['aiosp_opengraph_generate_descriptions'] ) ) && !empty( $post ) && !empty( $post->post_content ) && !post_password_required( $post ) )
                                    $description = $aiosp->trim_excerpt_without_filters( $aiosp->internationalize( preg_replace( '/\s+/', ' ', $post->post_content ) ), 1000 );
                Severity: Major
                Found in aioseop_opengraph.php - About 40 mins to fix

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

                                  'People' => Array(
                                      'actor' => __( 'Actor', 'all-in-one-seo-pack' ),
                                      'athlete' => __( 'Athlete', 'all-in-one-seo-pack' ),
                                      'author' => __( 'Author', 'all-in-one-seo-pack' ),
                                      'director' => __( 'Director', 'all-in-one-seo-pack' ),
                  Severity: Major
                  Found in aioseop_opengraph.php and 1 other location - About 2 hrs to fix
                  aioseop_bad_robots.php on lines 16..25

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status