Showing 12 of 14 total issues
File AnsiString.php
has 294 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Glhd\AnsiPants;
use Generator;
AnsiString
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class AnsiString implements Stringable
{
/** @var \Illuminate\Support\Collection<int,\Glhd\AnsiPants\AnsiChar> */
protected Collection $chars;
Function extractMetadata
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function extractMetadata(): void
{
preg_match("/^\e\[(\d+(?:;\d+)*)+m$/", $this->value, $matches);
$args = array_map('intval', explode(';', $matches[1]));
- 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
Consider simplifying this complex logical expression. Open
if (
($this->flag >= 30 && $this->flag < 37)
|| ($this->flag >= 40 && $this->flag < 47)
|| ($this->flag >= 90 && $this->flag < 97)
|| ($this->flag >= 100 && $this->flag < 107)
Function explode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function explode(AnsiString|string $break, bool $ignore_style = true): Collection
{
$break = new AnsiString($break);
$results = new Collection();
$buffer = new AnsiString('');
- 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 overrides
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function overrides(Flag $flag): bool
{
if ($this === self::Reset) {
return 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
Function words
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function words(?int $max_length): Generator
{
$sep = new static('');
$word = new static('');
- 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 wordwrap
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function wordwrap(int $width = 75, AnsiString|string $break = "\e[0m\n", bool $cut_long_words = false): static
{
$break = new AnsiString($break);
$buffer = new AnsiString('');
$wrapped = new AnsiString('');
- 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 substr
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function substr(int $start, ?int $length = null): static
{
if (0 === $length || $start >= $this->length()) {
return new static('');
}
- 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 true;
Avoid too many return
statements within this method. Open
return false;
Function diffFlags
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function diffFlags($a, $b): array
{
// Sadly array_diff doesn't work on enums :(
$remove = [];
$add = [];
- 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"