Showing 23 of 50 total issues
Function _inlineEscape
has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring. Open
private function _inlineEscape($inline)
{
// There's gotta be a cleaner way to do this...
// While pure sequences seem to be nesting just fine,
// pure mappings and mappings with sequences inside can't go very
- 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
Yaml
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class Yaml
{
// SETTINGS
const REMPTY = "\0\0\0\0\0";
Function _toType
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
private function _toType($value)
{
if ($value === '') {
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
Function addArray
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
private function addArray($incoming_data, $incoming_indent)
{
// print_r($incoming_data);
if (\count($incoming_data) > 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 (
\is_string($value)
&& ((\strpos($value, "\n") !== false || \strpos($value, ": ") !== false || \strpos($value, "- ") !== false
|| \strpos($value, "*") !== false || \strpos($value, "#") !== false || \strpos($value, "<") !== false
|| \strpos($value, ">") !== false || \strpos($value, '%') !== false || \strpos($value, ' ') !== false
Method _inlineEscape
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _inlineEscape($inline)
{
// There's gotta be a cleaner way to do this...
// While pure sequences seem to be nesting just fine,
// pure mappings and mappings with sequences inside can't go very
Function loadWithSource
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function loadWithSource($Source)
{
if (empty($Source)) {
return array();
}
- 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 _dumpNode
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null): string
{
// do some folding here, for blocks
if (
\is_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
Function _doLiteralBlock
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function _doLiteralBlock($value, int $indent): string
{
if ($value === "\n") {
return '\n';
}
- 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 dump
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function dump($array, int $indent = null, int $wordwrap = null): string
{
// Dumps to some very clean YAML. We'll have to add some more features
// and options soon. And better support for folding.
- 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 returnKeyValuePair
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function returnKeyValuePair($line)
{
$array = array();
$key = '';
if (\strpos($line, ': ')) {
- 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 _dumpNode
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null): string
Method _yamlize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function _yamlize($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null): string
Function coerceValue
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function coerceValue(&$value)
{
if (self::isTrueWord($value)) {
$value = true;
} else if (self::isFalseWord($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
Function revertLiteralPlaceHolder
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function revertLiteralPlaceHolder($lineArray, $literalBlock)
{
foreach ($lineArray as $k => $_) {
if (\is_array($_)) {
$lineArray[$k] = $this->revertLiteralPlaceHolder($_, $literalBlock);
- 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 _doFolding
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function _doFolding($value, $indent)
{
// Don't do anything if wordwrap is set to 0
if ($this->_dumpWordWrap !== 0 && \is_string($value) && \strlen($value) > $this->_dumpWordWrap) {
$indent += $this->_dumpIndent;
- 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 _yamlizeArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function _yamlizeArray($array, $indent): string
{
if (\is_array($array)) {
$string = '';
$previous_key = -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
Function nodeContainsGroup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function nodeContainsGroup($line)
{
$symbolsForReference = 'A-z0-9_\-';
if (\strpos($line, '&') === false && \strpos($line, '*') === false) {
return false;
- 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 _parseLine
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function _parseLine($line)
{
if (!$line) {
return array();
}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!empty($sequence)) {
foreach ($explode as $key => $value) {
if (\strpos($value, 'YAMLSeq') !== false) {
foreach ($sequence as $seqKey => $seq) {
$explode[$key] = \str_replace(('YAMLSeq' . $seqKey . 's'), $seq, $value);
- Read upRead up
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 90.
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