symplely/yaml

View on GitHub

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
Severity: Minor
Found in Yaml/Yaml.php - About 1 day to fix

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";

Severity: Major
Found in Yaml/Yaml.php - About 1 day to fix

    Function _toType has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        private function _toType($value)
        {
            if ($value === '') {
                return "";
            }
    Severity: Minor
    Found in Yaml/Yaml.php - About 6 hrs to fix

    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) {
    Severity: Minor
    Found in Yaml/Yaml.php - About 5 hrs to fix

    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
    Severity: Critical
    Found in Yaml/Yaml.php - About 4 hrs to fix

      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
      Severity: Major
      Found in Yaml/Yaml.php - About 4 hrs to fix

        Function loadWithSource has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            private function loadWithSource($Source)
            {
                if (empty($Source)) {
                    return array();
                }
        Severity: Minor
        Found in Yaml/Yaml.php - About 3 hrs to fix

        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)
        Severity: Minor
        Found in Yaml/Yaml.php - About 2 hrs to fix

        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';
                }
        Severity: Minor
        Found in Yaml/Yaml.php - About 1 hr to fix

        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.
        
        
        Severity: Minor
        Found in Yaml/Yaml.php - About 1 hr to fix

        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, ': ')) {
        Severity: Minor
        Found in Yaml/Yaml.php - About 55 mins to fix

        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
        Severity: Minor
        Found in Yaml/Yaml.php - About 45 mins to fix

          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
          Severity: Minor
          Found in Yaml/Yaml.php - About 45 mins to fix

            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)) {
            Severity: Minor
            Found in Yaml/Yaml.php - About 45 mins to fix

            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);
            Severity: Minor
            Found in Yaml/Yaml.php - About 35 mins to fix

            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;
            Severity: Minor
            Found in Yaml/Yaml.php - About 35 mins to fix

            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;
            Severity: Minor
            Found in Yaml/Yaml.php - About 35 mins to fix

            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;
            Severity: Minor
            Found in Yaml/Yaml.php - About 35 mins to fix

            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();
                    }
            Severity: Minor
            Found in Yaml/Yaml.php - About 35 mins to fix

            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);
            Severity: Minor
            Found in Yaml/Yaml.php and 1 other location - About 30 mins to fix
            Yaml/Yaml.php on lines 893..902

            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

            Further Reading

            Severity
            Category
            Status
            Source
            Language