Showing 143 of 143 total issues
Method createHeaderList
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function createHeaderList(): IHeaderList {
if (self::$headerList) {
return self::$headerList;
}
$headers = [];
- Create a ticketCreate a ticket
Method convert
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function convert($content, string $mime, string $target = null): IContent {
switch ($mime) {
/** @noinspection PhpMissingBreakStatementInspection */
case 'stream+application/json':
$content = file_get_contents($content);
- Create a ticketCreate a ticket
Method getTagList
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTagList(): array {
return [
'html',
'head',
'meta',
- Create a ticketCreate a ticket
Function tick
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function tick() {
$connectionList = $ignore = $readList = array_map(function (IConnection $connection) {
return $connection->getStream();
}, $this->connectionList);
if (($select = stream_select($readList, $ignore, $ignore, 3)) === false) {
- Read upRead up
- Create a ticketCreate a ticket
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 handleSetup
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function handleSetup() {
parent::handleSetup();
$cache = $this->cache();
if (($this->translationList = $cache->load($cacheId = implode(',', array_keys($this->fileList)))) === null) {
foreach ($this->fileList as $file) {
- Read upRead up
- Create a ticketCreate a ticket
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 match
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
static public function match(string $string, string $pattern, bool $named = false, bool $trim = false) {
$match = null;
$match = self::pcre('preg_match', [
$pattern,
$string,
- Read upRead up
- Create a ticketCreate a ticket
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 mime
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
static public function mime(string $file) {
if (is_file($file) === false) {
throw new FileException(sprintf('The given file [%s] is not a file.', $file));
}
$url = Url::create($file);
- Read upRead up
- Create a ticketCreate a ticket
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 onEnter
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function onEnter(INode $node, \Iterator $iterator, ...$parameters) {
switch ($node->getName()) {
case 'minify-css':
if ($this->minify) {
throw new MacroException(sprintf('Css minify does not support recursion.'));
- Read upRead up
- Create a ticketCreate a ticket
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 onEnter
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function onEnter(INode $node, \Iterator $iterator, ...$parameters) {
switch ($node->getName()) {
case 'minify-js':
if ($this->minify) {
throw new MacroException(sprintf('Js minify does not support recursion.'));
- Read upRead up
- Create a ticketCreate a ticket
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 createSchema
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createSchema(INode $node): ISchema {
$schema = new Schema($node->getName(), $node->getAttribute('namespace'));
$schema->setMetaList($node->getMetaList()->array());
$magic = $schema->getMeta('magic', true);
foreach ($this->propertyListNodeQuery->filter($node) as $propertyNode) {
- Create a ticketCreate a ticket
Method handleSetup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handleSetup() {
parent::handleSetup();
if (empty($this->schemaLoaderList)) {
throw new SchemaManagerException(sprintf('There are no schema loaders in [%s].', static::class));
}
- Create a ticketCreate a ticket
Method toAscii
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function toAscii(string $string): string {
$string = preg_replace('~[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]~u', '', $string);
$string = strtr($string, '`\'"^~?', "\x01\x02\x03\x04\x05\x06");
$string = str_replace([
"\xE2\x80\x9E",
- Create a ticketCreate a ticket
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (isset(self::$cache[$cacheId = 'property/' . (is_object($object) ? get_class($object) : $object) . $property]) === false) {
$reflectionClass = new ReflectionClass($object);
self::$cache[$cacheId] = $reflectionProperty = $reflectionClass->getProperty($property);
$reflectionProperty->setAccessible(true);
}
- Read upRead up
- Create a ticketCreate a ticket
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 103.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (isset(self::$cache[$cacheId = 'property/' . (is_object($object) ? get_class($object) : $object) . $property]) === false) {
$reflectionClass = new ReflectionClass($object);
self::$cache[$cacheId] = $reflectionProperty = $reflectionClass->getProperty($property);
$reflectionProperty->setAccessible(true);
}
- Read upRead up
- Create a ticketCreate a ticket
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 103.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function matchAll
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static public function matchAll(string $string, string $pattern, bool $named = false, $trim = false): array {
$match = null;
$match = self::pcre('preg_match_all', [
$pattern,
$string,
- Read upRead up
- Create a ticketCreate a ticket
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 accept
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static public function accept(string $accept = null): array {
if ($accept === null) {
return ['*/*'];
}
$accepts = [];
- Read upRead up
- Create a ticketCreate a ticket
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 language
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static public function language(string $language = null, string $default = 'en'): array {
if ($language === null) {
return [$default];
}
foreach (explode(',', $language) as $part) {
- Read upRead up
- Create a ticketCreate a ticket
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 onExecute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function onExecute(IElement $element) {
foreach ($this->requestHandlerList as $requestHandler) {
/** @var $response IElement */
if ($requestHandler->canHandle($element)) {
if (($response = $requestHandler->execute($element)) !== null && $response instanceof IElement) {
- Read upRead up
- Create a ticketCreate a ticket
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 charset
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static public function charset(string $charset = null, $default = 'utf-8'): array {
if ($charset === null) {
return [$default];
}
foreach (explode(',', $charset) as $part) {
- Read upRead up
- Create a ticketCreate a ticket
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 content
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function content(IContent $content, array $targetList = null): IConvertable {
$exception = null;
$unknown = true;
$mime = $content->getMime();
foreach ($targetList ?? [] as $target) {
- Read upRead up
- Create a ticketCreate a ticket
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"