edwrodrig/static_generator

View on GitHub

Showing 10 of 14 total issues

Function loadTemplateDataFromDoc has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadTemplateDataFromDoc(DocBlock $doc_block)
    {
        $template_class = '';

        $vars = $doc_block->getTagsByName('var');
Severity: Minor
Found in src/PagePhp.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

Context has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Context
{

    /**
     * @see Context::setLogger()
Severity: Minor
Found in src/Context.php - About 2 hrs to fix

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

        public static function addPart(string $name, $value, array &$parts) {
    
            if ( is_null($value) ) {
                return;
            } else if ( is_bool($value) && $value === true ) {
    Severity: Minor
    Found in src/html/Attributes.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 loadTypeDataFromDoc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function loadTypeDataFromDoc(DocBlock $doc_block){
            if ( $doc_block->hasTag('raw') ) {
                $this->mode = self::MODE_RAW;
    
            } else if ( $doc_block->hasTag('silent') ) {
    Severity: Minor
    Found in src/PagePhp.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

    Function isIgnore has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function isIgnore(string $filename) : bool {
            $filename = basename($filename);
            if ( preg_match('/^_.*\.scss$/', $filename) === 1)
                return true;
            else if ( preg_match('/\.swp$/', $filename) === 1)
    Severity: Minor
    Found in src/util/PageFileFactory.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

    Function createPage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function createPage(string $filename, Context $context) : PageFile {
            if ( self::isPhp($filename) ) {
                return new PagePhp($filename, $context);
            } else if ( self::isScss($filename) ) {
                return new PageScss($filename, $context);
    Severity: Minor
    Found in src/util/PageFileFactory.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

    Function generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generate() : string
        {
            $this->getLogger()->begin(sprintf("Processing file [%s]...", $this->getSourceRelativePath()));
    
            $content = '';
    Severity: Minor
    Found in src/PagePhp.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 tr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function tr($translatable, ?string $default = null, ?string $default_message = null) : string
        {
            if (isset($translatable[$this->getLang()]))
                return $translatable[$this->getLang()];
            else if (is_string($default)) {
    Severity: Minor
    Found in src/Context.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 createPages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function createPages(Context $context) {
    
    
            $iterator = new RecursiveDirectoryIterator(
                $context->getSourceRootPath(),
    Severity: Minor
    Found in src/util/PageFileFactory.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 getSourceFilename has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getSourceFilename() : string {
            if ( is_null($this->source_filename) ) {
                $this->source_filename = tempnam(sys_get_temp_dir(),'li_');
                file_put_contents($this->source_filename, $this->server->getImage($this->id));
    
    
    Severity: Minor
    Found in src/cache/contento/legacy/ImageItem.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