prismicio/php-kit

View on GitHub

Showing 36 of 36 total issues

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

        string $id,
        string $ref,
        string $label,
        bool   $isMasterRef,
        ?int   $maybeScheduledAt = null
Severity: Minor
Found in src/Prismic/Ref.php - About 35 mins to fix

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

        public function refFromCookie(?string $cookie) :? string
        {
            if (empty($cookie)) {
                return null;
            }
    Severity: Minor
    Found in src/Prismic/Experiments.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

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

        public function previewSession(string $token, LinkResolver $linkResolver, string $defaultUrl) : string
        {
            try {
                $response = $this->getHttpClient()->request('GET', $token);
            } catch (GuzzleException $guzzleException) {
    Severity: Minor
    Found in src/Prismic/Api.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

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

        private function submitRaw() : stdClass
        {
            if ($this->form->getMethod() !== 'GET' ||
                $this->form->getEnctype() !== 'application/x-www-form-urlencoded' ||
                ! $this->form->getAction()
    Severity: Minor
    Found in src/Prismic/SearchForm.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

    Avoid too many return statements within this method.
    Open

                    return (
                        '<p class="block-img' . (isset($element->label) ? (' ' . $element->label) : '') . '">' .
                        ($link ? '<a href="' . $link . '"' . $targetCode . '>' . $img . '</a>' : $img) .
                        '</p>'
                    );
    Severity: Major
    Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return nl2br('<h4' . $classCode . '>' . $content . '</h4>');
      Severity: Major
      Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return nl2br('<h5' . $classCode . '>' . $content . '</h5>');
        Severity: Major
        Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return '<pre' . $classCode . '>' . $content . '</pre>';
          Severity: Major
          Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return '';
            Severity: Major
            Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return nl2br('<p' . $classCode . '>' . $content . '</p>');
              Severity: Major
              Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $html;
                Severity: Major
                Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return nl2br('<li' . $classCode . '>' . $content . '</li>');
                  Severity: Major
                  Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return sprintf(
                                            '<div data-oembed="%s" data-oembed-type="%s"%s>%s</div>',
                                            $element->oembed->embed_url,
                                            strtolower($element->oembed->type),
                                            $providerAttr,
                    Severity: Major
                    Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return nl2br('<h6' . $classCode . '>' . $content . '</h6>');
                      Severity: Major
                      Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return $content;
                        Severity: Major
                        Found in src/Prismic/Dom/RichText.php - About 30 mins to fix

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

                              public function defaultData() : array
                              {
                                  /**
                                   * @var string    $key
                                   * @var FieldForm $field
                          Severity: Minor
                          Found in src/Prismic/Form.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