original-brownbear/php-transpiler

View on GitHub

Showing 6 of 6 total issues

Function stripWhiteSpaces has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function stripWhiteSpaces()
    {
        $hasOpeningTag   = strpos($this->source, '<?php') === false;
        $tokens          = token_get_all(($hasOpeningTag ? '<?php ' : '') . $this->source);
        $sanitizedTokens = array();
Severity: Minor
Found in src/PhpTranspiler/Framework/PhpSourceSanitization.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 properties has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function properties()
    {
        $nodes      = $this->method->asNode()->stmts;
        $properties = array();
        foreach ($nodes as $node) {
Severity: Minor
Found in src/PhpTranspiler/Framework/SourceElements/PropertyAccess.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

Method stripWhiteSpaces has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function stripWhiteSpaces()
    {
        $hasOpeningTag   = strpos($this->source, '<?php') === false;
        $tokens          = token_get_all(($hasOpeningTag ? '<?php ' : '') . $this->source);
        $sanitizedTokens = array();
Severity: Minor
Found in src/PhpTranspiler/Framework/PhpSourceSanitization.php - About 1 hr to fix

    Function run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run()
        {
            $nodes = $this->file->sourceTree();
            foreach ($nodes as &$node) {
                if ($node->getType() === 'Stmt_Class') {

    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 copyTo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function copyTo($path, $src = null)
        {
            $dir = $src ? opendir($src) : $this->getHandle();
            if ( ! is_dir($path)) {
                mkdir($path, 0777, true);
    Severity: Minor
    Found in src/PhpTranspiler/Framework/SourceDir.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 getFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getFiles()
        {
            $handle = $this->getHandle();
            $files  = array();
            while (false !== ($entry = readdir($handle))) {
    Severity: Minor
    Found in src/PhpTranspiler/Framework/SourceDir.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

    Severity
    Category
    Status
    Source
    Language