francis94c/ci-gmail

View on GitHub

Showing 8 of 8 total issues

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

  function build_url_query(array $params, bool $urlEncode=true):?string {
    if ($params == null) return null;
    $queryString = '?';
    foreach($params as $key => $val) {
      if (is_array($val)) {
Severity: Minor
Found in helpers/curl_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 getMessages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  public function getMessages(string $userId='me', array $labelIds=null,
  string $q=null, int $maxMessages=null, string $pageToken=null, bool $includeSpamTrash=false,
  $truncateAfter=null):?object
  {
    $query = [];
Severity: Minor
Found in libraries/GMail.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 getToken has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public function getToken(string $code, string $redirectUri=null):?object
  {
    $redirectUri = $redirectUri ?? $this->redirectUri;
    $ch = curl_init(self::TOKEN_URL);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Severity: Minor
Found in libraries/GMail.php - About 1 hr to fix

    Method refreshAccessToken has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public function refreshAccessToken(string $refreshToken):?object
      {
        $ch = curl_init(self::TOKEN_URL);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    Severity: Minor
    Found in libraries/GMail.php - About 1 hr to fix

      Method getMessages has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public function getMessages(string $userId='me', array $labelIds=null,
        string $q=null, int $maxMessages=null, string $pageToken=null, bool $includeSpamTrash=false,
        $truncateAfter=null):?object
        {
          $query = [];
      Severity: Minor
      Found in libraries/GMail.php - About 1 hr to fix

        Method getMessages has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          public function getMessages(string $userId='me', array $labelIds=null,
          string $q=null, int $maxMessages=null, string $pageToken=null, bool $includeSpamTrash=false,
          $truncateAfter=null):?object
        Severity: Major
        Found in libraries/GMail.php - About 50 mins to fix

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

            public function getAuthorizeUrl(string $scope, string $redirectUri=null,
            string $responseType='code', string $accessType='offline', bool $prompt=false):string
          Severity: Minor
          Found in libraries/GMail.php - About 35 mins to fix

            Function __invoke has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              function __invoke(string $url, array $header=[], array $body=null):array {
                if ($body != null) $body = json_encode($body);
            
                $ch = curl_init($url);
            
            Severity: Minor
            Found in libraries/GMailCURL.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

            Severity
            Category
            Status
            Source
            Language