silktide/semrush-api

View on GitHub

Showing 8 of 8 total issues

Client has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class Client
{
    use LoggerAwareTrait;
    use ApiUsageTracker;

Severity: Minor
Found in src/Client.php - About 3 hrs to fix

    File Client.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Silktide\SemRushApi;
    
    use DateInterval;
    Severity: Minor
    Found in src/Client.php - About 2 hrs to fix

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

          protected function validateDomains($key, $domains)
          {
              $parts = explode('|', $domains);
      
              if (count($parts) > 5 * 3) { // 5 domains max, each with 3 parts
      Severity: Minor
      Found in src/Model/Request.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 getApiUsage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getApiUsage(Request $request, Result $response): int
          {
              $usage = 1;
              $options = $request->buildOptionsArray($request->getUrlParameters());
      
      
      Severity: Minor
      Found in src/Client.php - About 1 hr to fix

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

            protected function validateOption($option, $value)
            {
                $fieldDefinitions = $this->definition->getAvailableFields();
                $fieldType = $fieldDefinitions[$option];
                switch ($fieldType) {
        Severity: Minor
        Found in src/Model/Request.php - About 1 hr to fix

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

              protected function validateOption($option, $value)
              {
                  $fieldDefinitions = $this->definition->getAvailableFields();
                  $fieldType = $fieldDefinitions[$option];
                  switch ($fieldType) {
          Severity: Minor
          Found in src/Model/Request.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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  string $apiKey,
                  RequestFactory $requestFactory,
                  ResponseParser $responseParser,
                  ResultFactory $resultFactory,
                  UrlBuilder $urlBuilder,
          Severity: Minor
          Found in src/Client.php - About 45 mins to fix

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

                public function getApiUsage(Request $request, Result $response): int
                {
                    $usage = 1;
                    $options = $request->buildOptionsArray($request->getUrlParameters());
            
            
            Severity: Minor
            Found in src/Client.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

            Severity
            Category
            Status
            Source
            Language