Showing 17 of 1,364 total issues
File RobotsTxtParser.php
has 353 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types=1);
namespace t1gor\RobotsTxtParser;
use Psr\Log\LoggerAwareInterface;
RobotsTxtParser
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class RobotsTxtParser implements LoggerAwareInterface {
use LogsIfAvailableTrait;
// default encoding
Function parseURL
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function parseURL($url) {
$parsed = parse_url($url);
if ($parsed === false) {
return false;
} elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
- 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 render
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function render($eol = "\r\n") {
$input = $this->getRules();
krsort($input);
$output = [];
foreach ($input as $userAgent => $rules) {
- 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 filter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function filter($in, $out, &$consumed, $closing) {
while ($bucket = stream_bucket_make_writeable($in)) {
$skippedRequestRateValues = 0;
$skippedCrawlDelayValues = 0;
$skippedAllowanceValues = 0;
- 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 process
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(string $line, array &$root, string &$currentUserAgent = '*', string $prevLine = '') {
$parts = explode(':', $line);
$entry = trim($parts[1]);
$directive = $this->getDirectiveName();
Method render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render($eol = "\r\n") {
$input = $this->getRules();
krsort($input);
$output = [];
foreach ($input as $userAgent => $rules) {
Function getSitemaps
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getSitemaps(?string $userAgent = null): array {
$this->buildTree();
$maps = [];
if (!is_null($userAgent)) {
- 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 checkRules
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function checkRules(string $rule, string $path, string $userAgent = '*'): bool {
// check for disallowed http status code
if ($this->checkHttpStatusCodeRule()) {
return ($rule === Directive::DISALLOW);
}
- 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 parse
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function parse(string $url) {
$parsed = parse_url($url);
if ($parsed === false) {
$this->log("Failed to parse URL from {$url}");
- 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 __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$content,
string $encoding = self::DEFAULT_ENCODING,
?TreeBuilderInterface $treeBuilder = null,
?ReaderInterface $reader = null,
?UserAgentMatcherInterface $userAgentMatcher = null
Method processDirective
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function processDirective(string $directive, string $line, &$tree, string &$userAgent, string $prevLine = '') {
Function build
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function build(): array {
$currentUserAgent = '*';
$tree = [];
$prevLine = '';
- 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 getHost
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getHost(?string $userAgent = null) {
$this->buildTree();
if (!is_null($userAgent)) {
$userAgent = $this->userAgentMatcher->getMatching($userAgent, array_keys($this->tree));
- 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
Avoid too many return
statements within this method. Open
return $parsed;
Avoid too many return
statements within this method. Open
return $parsed;
Function __destruct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function __destruct() {
foreach ($this->filters as $class => $instance) {
try {
if (is_resource($instance)) {
stream_filter_remove($instance);
- 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"