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;
}
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);
- Read upRead up
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;
Target
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class Target
{
private const INITIAL_CURSOR = 0;
private string $name;
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;
- Read upRead up
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 {
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;
}
- Read upRead up
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()]);
}
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
string $name,
string $model,
string $source,
array $markup,
array $pager = [],
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])) {
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 {
- Read upRead up
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()]);
}
- Read upRead up
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 = []
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])) {
- Read upRead up
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);
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)) {
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)) {
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);
}
- Read upRead up
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}");
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/>';
- Read upRead up
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"