reliqarts/laravel-scavenger

View on GitHub

Showing 27 of 27 total issues

Method scrape has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function scrape(Target $target, ?Crawler $crawler): void
    {
        if ($crawler === null) {
            return;
        }
Severity: Major
Found in src/Service/Seeker.php - About 4 hrs to fix

    Function preprocess has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        private function preprocess(array $data, Target $target): array
        {
            // preprocess and remap scrap data parts
            foreach ($data as $attr => $value) {
                $data[$attr] = $this->encodeAttribute($attr, (string)$value);
    Severity: Minor
    Found in src/Service/Scrapper.php - About 3 hrs 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

    File Seeker.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    namespace ReliqArts\Scavenger\Service;
    Severity: Minor
    Found in src/Service/Seeker.php - About 3 hrs to fix

      Target has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Target
      {
          private const INITIAL_CURSOR = 0;
      
          private string $name;
      Severity: Minor
      Found in src/Model/Target.php - About 2 hrs to fix

        Function convert has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function convert(bool $convertDuplicates = false, bool $storeRelatedReference = false): ?EloquentModel
            {
                $targetObject = null;
                $convert = true;
        
        
        Severity: Minor
        Found in src/Model/Scrap.php - About 2 hrs 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 seek has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function seek(
                OptionSet $options,
                ?string $targetName = null,
                ?Command $callingCommand = null
            ): Result {
        Severity: Major
        Found in src/Service/Seeker.php - About 2 hrs to fix

          Function scrape has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private function scrape(Target $target, ?Crawler $crawler): void
              {
                  if ($crawler === null) {
                      return;
                  }
          Severity: Minor
          Found in src/Service/Seeker.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 searchAndScrape has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function searchAndScrape(Target $target, Crawler $crawler): void
              {
                  if ($this->verbosity >= self::VERBOSITY_MEDIUM) {
                      $this->logger->info('Landing Document', [$crawler->html()]);
                  }
          Severity: Minor
          Found in src/Service/Seeker.php - About 1 hr to fix

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

                    string $name,
                    string $model,
                    string $source,
                    array $markup,
                    array $pager = [],
            Severity: Major
            Found in src/Model/Target.php - About 1 hr to fix

              Method validateDefinition has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function validateDefinition(array $definition): Result
                  {
                      $result = new Result(true);
              
                      if (empty($definition[TargetKey::NAME])) {
              Severity: Minor
              Found in src/Factory/TargetBuilder.php - About 1 hr to fix

                Function seek has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function seek(
                        OptionSet $options,
                        ?string $targetName = null,
                        ?Command $callingCommand = null
                    ): Result {
                Severity: Minor
                Found in src/Service/Seeker.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

                Function searchAndScrape has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function searchAndScrape(Target $target, Crawler $crawler): void
                    {
                        if ($this->verbosity >= self::VERBOSITY_MEDIUM) {
                            $this->logger->info('Landing Document', [$crawler->html()]);
                        }
                Severity: Minor
                Found in src/Service/Seeker.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 initializeData has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function initializeData(
                        TitleLink $titleLink,
                        Target $target,
                        Crawler $crawler,
                        array $markupOverride = []
                Severity: Minor
                Found in src/Service/Scrapper.php - About 1 hr to fix

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

                      public static function firstNonEmpty(array $haystack, array $needles = [])
                      {
                          if (!empty($needles)) {
                              foreach ($needles as $value) {
                                  if (!empty($haystack[$value])) {
                  Severity: Minor
                  Found in src/Service/Scanner.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 preprocess has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function preprocess(array $data, Target $target): array
                      {
                          // preprocess and remap scrap data parts
                          foreach ($data as $attr => $value) {
                              $data[$attr] = $this->encodeAttribute($attr, (string)$value);
                  Severity: Minor
                  Found in src/Service/Scrapper.php - About 1 hr to fix

                    Method validateMarkupDefinition has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function validateMarkupDefinition(?array $markupDefinition, string $targetName): Result
                        {
                            $result = new Result(true);
                    
                            if (empty($markupDefinition)) {
                    Severity: Minor
                    Found in src/Factory/TargetBuilder.php - About 1 hr to fix

                      Method validateSearchDefinition has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function validateSearchDefinition(?array $searchDefinition, string $targetName): Result
                          {
                              $result = new Result(true);
                      
                              if (empty($searchDefinition)) {
                      Severity: Minor
                      Found in src/Factory/TargetBuilder.php - About 1 hr to fix

                        Function closest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function closest(string $selector, Crawler $crawler): ?Crawler
                            {
                                if (!count($crawler)) {
                                    throw new InvalidArgumentException(self::CURRENT_NODE_LIST_EMPTY);
                                }
                        Severity: Minor
                        Found in src/Helper/NodeProximityAssistant.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 showResult has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function showResult(Result $result): void
                            {
                                if (!$result->isSuccess()) {
                                    foreach ($result->getErrors() as $errorMessage) {
                                        $this->line(PHP_EOL . "<error>✘</error> {$errorMessage}");
                        Severity: Minor
                        Found in src/Console/Command/Seek.php - About 1 hr to fix

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

                              final protected function tell(string $text, string $direction = self::COMM_DIRECTION_OUT): void
                              {
                                  $direction = strtolower($direction);
                                  $nl = app()->runningInConsole() ? "\n" : '<br/>';
                          
                          
                          Severity: Minor
                          Found in src/Service/Communicator.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

                          Severity
                          Category
                          Status
                          Source
                          Language