eventfarm/marketo-client

View on GitHub

Showing 11 of 11 total issues

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

<?php
namespace EventFarm\Marketo\API;

use EventFarm\Marketo\RestClient\MarketoRestClient;

Severity: Major
Found in src/API/Partitions.php and 2 other locations - About 4 hrs to fix
src/API/LeadFields.php on lines 1..36
src/API/Programs.php on lines 1..36

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 172.

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 3 locations. Consider refactoring.
Open

<?php
namespace EventFarm\Marketo\API;

use EventFarm\Marketo\RestClient\MarketoRestClient;

Severity: Major
Found in src/API/LeadFields.php and 2 other locations - About 4 hrs to fix
src/API/Partitions.php on lines 1..36
src/API/Programs.php on lines 1..36

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 172.

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 3 locations. Consider refactoring.
Open

<?php
namespace EventFarm\Marketo\API;

use EventFarm\Marketo\RestClient\MarketoRestClient;

Severity: Major
Found in src/API/Programs.php and 2 other locations - About 4 hrs to fix
src/API/LeadFields.php on lines 1..36
src/API/Partitions.php on lines 1..36

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 172.

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

    public function triggerCampaign(int $campaignId, array $options)//:stdClass
    {
        $endpoint = '/rest/v1/campaigns/' . $campaignId . '/trigger.json';

        $requestOptions = [
Severity: Major
Found in src/API/Campaigns.php and 1 other location - About 1 hr to fix
src/API/Leads.php on lines 42..63

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 120.

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

    public function updateLeadsProgramStatus(int $programId, array $options = array())
    {
        $endpoint = '/rest/v1/leads/programs/' . $programId . '/status.json';

        $requestOptions = [
Severity: Major
Found in src/API/Leads.php and 1 other location - About 1 hr to fix
src/API/Campaigns.php on lines 37..58

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 120.

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 isTokenValid has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function isTokenValid($responseBody):bool
    {
        /* Depending on the endpoint, the JSON Marketo returns will always contain an errors key (like getPrograms
        does) or will only contain an errors key if there are errors (like getCampaigns does) */
        if (property_exists($responseBody, "errors")) {
Severity: Minor
Found in src/RestClient/MarketoRestClient.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 withDefaults has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

        string $accessToken,
        int $tokenExpiresIn,
        int $tokenLastRefresh,
        string $clientId,
        string $clientSecret,
Severity: Major
Found in src/MarketoClient.php - About 1 hr to fix

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

            RestClientInterface $restClient,
            MarketoProviderInterface $marketoProvider,
            string $accessToken,
            int $tokenExpiresIn,
            int $tokenLastRefresh,
    Severity: Major
    Found in src/MarketoClient.php - About 50 mins to fix

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

              RestClientInterface $restClient,
              MarketoProviderInterface $marketoProvider,
              AccessToken $accessToken,
              $tokenRefreshObject,
              int $maxRetryRequests
      Severity: Minor
      Found in src/MarketoClient.php - About 35 mins to fix

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

                RestClientInterface $restClient,
                MarketoProviderInterface $marketoProvider,
                AccessToken $accessToken,
                TokenRefreshInterface $tokenRefreshCallback = null,
                int $maxRetryRequests
        Severity: Minor
        Found in src/RestClient/MarketoRestClient.php - About 35 mins to fix

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

              private function retryRequest(string $method, string $uri, array $options):ResponseInterface
              {
                  $attempts = 0;
                  do {
                      $expirationTime = $this->accessToken->getLastRefresh() + $this->accessToken->getExpires();
          Severity: Minor
          Found in src/RestClient/MarketoRestClient.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