bcit-ci/CodeIgniter

View on GitHub
system/helpers/url_helper.php

Summary

Maintainability
D
2 days
Test Coverage

Function safe_mailto has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    function safe_mailto($email, $title = '', $attributes = '')
    {
        $title = (string) $title;

        if ($title === '')
Severity: Minor
Found in system/helpers/url_helper.php - About 5 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

File url_helper.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP
Severity: Minor
Found in system/helpers/url_helper.php - About 3 hrs to fix

    Method safe_mailto has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function safe_mailto($email, $title = '', $attributes = '')
        {
            $title = (string) $title;
    
            if ($title === '')
    Severity: Major
    Found in system/helpers/url_helper.php - About 3 hrs to fix

      Function auto_link has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          function auto_link($str, $type = 'both', $popup = FALSE)
          {
              // Find and replace any URLs.
              if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER))
              {
      Severity: Minor
      Found in system/helpers/url_helper.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 redirect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          function redirect($uri = '', $method = 'auto', $code = NULL)
          {
              if ( ! preg_match('#^(\w+:)?//#i', $uri))
              {
                  $uri = site_url($uri);
      Severity: Minor
      Found in system/helpers/url_helper.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 anchor_popup has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function anchor_popup($uri = '', $title = '', $attributes = FALSE)
          {
              $title = (string) $title;
              $site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
      
      
      Severity: Minor
      Found in system/helpers/url_helper.php - About 1 hr to fix

        Method redirect has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function redirect($uri = '', $method = 'auto', $code = NULL)
            {
                if ( ! preg_match('#^(\w+:)?//#i', $uri))
                {
                    $uri = site_url($uri);
        Severity: Minor
        Found in system/helpers/url_helper.php - About 1 hr to fix

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

              function anchor_popup($uri = '', $title = '', $attributes = FALSE)
              {
                  $title = (string) $title;
                  $site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
          
          
          Severity: Minor
          Found in system/helpers/url_helper.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 url_title has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              function url_title($str, $separator = '-', $lowercase = FALSE)
              {
                  if ($separator === 'dash')
                  {
                      $separator = '-';
          Severity: Minor
          Found in system/helpers/url_helper.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

          There are no issues that match your filters.

          Category
          Status