PressLabs/toplytics

View on GitHub

Showing 53 of 56 total issues

Method serviceConnect has 34 lines of code (exceeds 25 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

    Method printInput has 34 lines of code (exceeds 25 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

      Method extraRowMeta has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function extraRowMeta($plugin_meta, $plugin_file = null)
          {
              global $toplytics_engine;
      
              if ( ! is_null( $plugin_file ) && $plugin_file !== $this->plugin_basename ) {
      Severity: Minor
      Found in src/components/Backend.php - About 1 hr to fix

        Method showTheTop has 31 lines of code (exceeds 25 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

          Method getAnalyticsRealTimeData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getAnalyticsRealTimeData( $extended_fetch = false )
              {
                  if ( ! $this->checkSetting('fetch_realtime') ) {
                      return [];
                  }
          Severity: Minor
          Found in src/components/Backend.php - About 1 hr to fix

            Method openWindowToSettingsView has 29 lines of code (exceeds 25 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

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

                  public function getAuthConfig()
                  {
                      $authType = get_option('toplytics_auth_type');
              
                      if ($authType == 'private') {
              Severity: Minor
              Found in src/components/Backend.php - About 1 hr to fix

                Method updateAnalyticsDataResults has 28 lines of code (exceeds 25 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

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

                      private function getAnalyticsRealTimeData( $extended_fetch = false )
                      {
                          if ( ! $this->checkSetting('fetch_realtime') ) {
                              return [];
                          }
                  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 getProfiles has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getProfiles()
                      {
                          $profiles = [];
                          $accounts = $this->getAccounts();
                          foreach ($accounts as $account_id => $account_name) {
                  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

                  Consider simplifying this complex logical expression.
                  Open

                          if (!empty($args['input']) && ($args['input'] == 'text' || $args['input'] == 'color')) {
                              echo "<input type='text' id='" . $args['id'] . "' name='" . $option . "[" . $args['id'] . "]' value='" . (!empty($settings[$args['id']]) ? $settings[$args['id']] : '') . "' placeholder='" . (!empty($args['placeholder']) ? $args['placeholder'] : '') . "' " . (!empty($args['disabled']) && $args['disabled'] ? 'readonly="readonly"' : '') . " />";
                          }
                  
                          //Select
                  Severity: Major
                  Found in src/components/Backend.php - About 1 hr to fix

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

                        public function act_before_settings_update($updated_settings)
                        {
                            // Fetch the current set of Toplytics settings from the DB.
                            $current_settings = get_option('toplytics_settings');
                    
                    
                    Severity: Minor
                    Found in src/components/Backend.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 updateAnalyticsRealTimeDataResults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function updateAnalyticsRealTimeDataResults( $extended_fetch = false )
                        {
                            try {
                                $realtime = $this->getAnalyticsRealTimeData( $extended_fetch );
                            } catch (Exception $e) {
                    Severity: Minor
                    Found in src/components/Backend.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 form has a Cognitive Complexity of 8 (exceeds 5 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: Minor
                    Found in src/components/Widget.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 _get_featured_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function _get_featured_image( $post_id )
                        {
                            $featured_image = $image_size = ''; // Sensible default.
                            if ( $this->checkSetting( 'include_featured_image_in_json' ) ) {
                                // Check if a value is set for the featured image size.
                    Severity: Minor
                    Found in src/components/Backend.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

                    Method add has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
                    Severity: Minor
                    Found in src/components/Loader.php - About 45 mins to fix

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

                          public function getAuthConfig()
                          {
                              $authType = get_option('toplytics_auth_type');
                      
                              if ($authType == 'private') {
                      Severity: Minor
                      Found in src/components/Backend.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 serviceDisconnect has a Cognitive Complexity of 8 (exceeds 5 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 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

                      Method notifyAdmins has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function notifyAdmins($type, $message, $dismiss = true, $style = '', $lateLoad = false)
                      Severity: Minor
                      Found in src/components/Window.php - About 35 mins to fix

                        Method addAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public function addAction($hook, $component, $callback, $priority = 10, $accepted_args = 1)
                        Severity: Minor
                        Found in src/components/Loader.php - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language