BaguettePHP/mastodon-api

View on GitHub
src/functions.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

function session($instance, $client_id, $client_secret, array $options)
{
    $scope = null;
    $grant = null;
    $authorization = null;
Severity: Minor
Found in src/functions.php - About 1 hr to fix

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

    function request(Mastodon $service, $method, $path, $options, $class = null)
    Severity: Minor
    Found in src/functions.php - About 35 mins to fix

      Function session has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function session($instance, $client_id, $client_secret, array $options)
      {
          $scope = null;
          $grant = null;
          $authorization = null;
      Severity: Minor
      Found in src/functions.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

      Missing class import via use statement (line '127', column '30').
      Open

              $cached_client = new \GuzzleHttp\Client;
      Severity: Minor
      Found in src/functions.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Call to method __construct from undeclared class \GuzzleHttp\Client (Did you mean class \Baguette\Mastodon\Client)
      Open

              $cached_client = new \GuzzleHttp\Client;
      Severity: Critical
      Found in src/functions.php by phan

      Return type of http() is undeclared type \GuzzleHttp\ClientInterface
      Open

      function http(\GuzzleHttp\ClientInterface $client = null)
      Severity: Minor
      Found in src/functions.php by phan

      Return type of request() is undeclared type \Psr\Http\Message\ResponseInterface
      Open

      function request(Mastodon $service, $method, $path, $options, $class = null)
      Severity: Minor
      Found in src/functions.php by phan

      Call to undeclared function \GuzzleHttp\json_decode() (Did you mean \json_decode() or \json_encode())
      Open

          return Entity\map($class, \GuzzleHttp\json_decode($response->getBody(), true));
      Severity: Critical
      Found in src/functions.php by phan

      Parameter $client has undeclared type ?\GuzzleHttp\ClientInterface
      Open

      function http(\GuzzleHttp\ClientInterface $client = null)
      Severity: Minor
      Found in src/functions.php by phan

      Saw possibly unextractable annotation for a fragment of comment '* @param Scope|string|string[]': after Scope|string|string[], did not see an element name (will guess based on comment order)
      Open

       * @param  Scope|string|string[]
      Severity: Info
      Found in src/functions.php by phan

      Cannot access private property \Baguette\Mastodon\Mastodon->client defined at src/Mastodon.php:29
      Open

          $response = $service->client->requestAPI($method, $path, $options, $service->session);
      Severity: Critical
      Found in src/functions.php by phan

      Cannot access private property \Baguette\Mastodon\Mastodon->session defined at src/Mastodon.php:31
      Open

          $response = $service->client->requestAPI($method, $path, $options, $service->session);
      Severity: Critical
      Found in src/functions.php by phan

      Call to deprecated function \Baguette\Mastodon\credential() defined at src/functions.php:92
      Open

              $grant = credential($options['credential']);
      Severity: Minor
      Found in src/functions.php by phan

      There are no issues that match your filters.

      Category
      Status