bluefyn-international/ShipEngine

View on GitHub

Showing 10 of 10 total issues

Method sendRequest has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function sendRequest(
        string $method,
        string $path,
        ?array $body,
        ShipEngineConfig $config
Severity: Major
Found in src/ShipEngineClient.php - About 2 hrs to fix

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

        public function __construct(array $config = [])
        {
            $assert = new Assert();
            $api_key = $config['apiKey'] ?? config('shipengine.credentials.key');
            $assert->isApiKeyValid($api_key);
    Severity: Minor
    Found in src/ShipEngineConfig.php - About 1 hr to fix

      Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              string $message,
              public string|null $requestId = null,
              public string|null $source = null,
              public string|null $type = null,
              public string|null $errorCode = null,
      Severity: Minor
      Found in src/Message/ShipEngineException.php - About 45 mins to fix

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

                string $directory,
                string $subDirectory,
                string $fileName,
                array $params = [],
                array|ShipEngineConfig|null $config = null,
        Severity: Minor
        Found in src/Traits/Downloads.php - About 35 mins to fix

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

                  string $warehouse_id,
                  string $name,
                  array $origin_address,
                  array $return_address = [],
                  array|ShipEngineConfig|null $config = null,
          Severity: Minor
          Found in src/Traits/Warehouse.php - About 35 mins to fix

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

                    string $path,
                    array|null $params,
                    array|ShipEngineConfig $config,
                    string $responseKey,
                    string $responseType,
            Severity: Minor
            Found in src/Traits/BaseCalls.php - About 35 mins to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  protected function getLabel(
                      string $path,
                      array $params = [],
                      array|ShipEngineConfig|null $config = null,
                  ) : array|Label {
              Severity: Minor
              Found in src/Traits/Labels.php and 1 other location - About 35 mins to fix
              src/Traits/Labels.php on lines 146..164

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 92.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  protected function postLabel(
                      string $path,
                      array $payload = [],
                      array|ShipEngineConfig|null $config = null,
                  ) : array|Label {
              Severity: Minor
              Found in src/Traits/Labels.php and 1 other location - About 35 mins to fix
              src/Traits/Labels.php on lines 123..141

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 92.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                  private static function sendRequest(
                      string $method,
                      string $path,
                      ?array $body,
                      ShipEngineConfig $config
              Severity: Minor
              Found in src/ShipEngineClient.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

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

                  private static function sendRequestWithRetries(
                      string $method,
                      string $path,
                      ?array $body,
                      ShipEngineConfig $config
              Severity: Minor
              Found in src/ShipEngineClient.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

              Severity
              Category
              Status
              Source
              Language