PressLabs/toplytics

View on GitHub
src/components/Widget.php

Summary

Maintainability
C
1 day
Test Coverage

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

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

          public function update($new_instance, $old_instance)
          {
              $instance = $old_instance;
              $instance['title'] = strip_tags($new_instance['title']);
      
      
      Severity: Minor
      Found in src/components/Widget.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

      There are no issues that match your filters.

      Category
      Status