PressLabs/toplytics

View on GitHub

Showing 56 of 56 total issues

File Backend.php has 1398 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Toplytics;

use Exception;
Severity: Major
Found in src/components/Backend.php - About 3 days to fix

    Function convertDataToPosts has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

        private function convertDataToPosts($data, $when)
        {
            $new_data = [];
    
            if ($this->checkSetting('ignore_posts_ids')) {
    Severity: Minor
    Found in src/components/Backend.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

    Backend has 62 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Backend
    {
    
        /**
         * The ID of this plugin.
    Severity: Major
    Found in src/components/Backend.php - About 1 day to fix

      Method initSettings has 214 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function initSettings()
          {
              $options = get_option('toplytics_settings');
              if ($options == false) {
                  $options = $this->getDefaultSettings();
      Severity: Major
      Found in src/components/Backend.php - About 1 day to fix

        Method widget has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function widget($args, $instance)
            {
        
                ob_start();
        
        
        Severity: Major
        Found in src/components/Widget.php - About 3 hrs to fix

          Function widget has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              public function widget($args, $instance)
              {
          
                  ob_start();
          
          
          Severity: Minor
          Found in src/components/Widget.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

          Method form has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function form($instance)
              {
                  $widget_title = isset($instance['title']) ? esc_attr($instance['title']) : '';
          
                  if (!isset($instance['numberposts']) || !$widget_numberposts = (int) $instance['numberposts']) {
          Severity: Major
          Found in src/components/Widget.php - About 2 hrs to fix

            Method convertDataToPosts has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function convertDataToPosts($data, $when)
                {
                    $new_data = [];
            
                    if ($this->checkSetting('ignore_posts_ids')) {
            Severity: Major
            Found in src/components/Backend.php - About 2 hrs to fix

              Function update_additional_posts_data has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function update_additional_posts_data()
                  {
                      // Fetch the widgets data from the database, if not already retrieved.
                      $this->_maybe_fetch_widgets_data();
              
              
              Severity: Minor
              Found in src/components/Backend.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

              Method getAnalyticsData has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getAnalyticsData( $extended_fetch = false )
                  {
                      $propertyId = get_option('toplytics_property_id', false);
              
                      if (!$propertyId) return false;
              Severity: Major
              Found in src/components/Backend.php - About 2 hrs to fix

                Method update_additional_posts_data has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function update_additional_posts_data()
                    {
                        // Fetch the widgets data from the database, if not already retrieved.
                        $this->_maybe_fetch_widgets_data();
                
                
                Severity: Major
                Found in src/components/Backend.php - About 2 hrs to fix

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

                      private function _have_enough_results( $posts, $period )
                      {
                          // Fetch the widgets data from the database, if not already retrieved.
                          $this->_maybe_fetch_widgets_data();
                  
                  
                  Severity: Minor
                  Found in src/components/Backend.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 printInput has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function printInput($args)
                      {
                          $option = 'toplytics_settings';
                          $settings = get_option($option);
                  
                  
                  Severity: Minor
                  Found in src/components/Backend.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 getAnalyticsData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getAnalyticsData( $extended_fetch = false )
                      {
                          $propertyId = get_option('toplytics_property_id', false);
                  
                          if (!$propertyId) return false;
                  Severity: Minor
                  Found in src/components/Backend.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 privateAuthorization has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function privateAuthorization()
                      {
                          if (empty($_POST['ToplyticsSubmitPrivateAuthorization'])) {
                              return false;
                          }
                  Severity: Minor
                  Found in src/components/Backend.php - About 1 hr to fix

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

                        private function showTheTop($args)
                        {
                            $args = $this->validateArgs($args);
                            // Parse category argument as integer, if present in the shortcode.
                            $category = ( ! empty( $args['category'] ) ) ? intval( $args['category'] ) : 0;
                    Severity: Minor
                    Found in src/components/Shortcode.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 updateAnalyticsDataResults has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function updateAnalyticsDataResults( $extended_fetch = false )
                        {
                            try {
                                $data = $this->getAnalyticsData( $extended_fetch );
                            } catch (Exception $e) {
                    Severity: Minor
                    Found in src/components/Backend.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 openWindowToSettingsView has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function openWindowToSettingsView()
                        {
                            if (get_option('toplytics_google_token')) {
                                $profile = get_option('toplytics_profile_data');
                    
                    
                    Severity: Minor
                    Found in src/components/Backend.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 serviceConnect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function serviceConnect()
                        {
                            if (!$this->client) {
                                return false;
                            }
                    Severity: Minor
                    Found in src/components/Backend.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 serviceDisconnect has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function serviceDisconnect($programatic = false, $silent = false)
                        {
                            if (empty($_POST['ToplyticsSubmitAccountDisconnect']) && !$programatic) {
                                return;
                            }
                    Severity: Minor
                    Found in src/components/Backend.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language