edde-framework/edde-framework

View on GitHub

Showing 143 of 143 total issues

Method createHeaderList has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        static public function createHeaderList(): IHeaderList {
            if (self::$headerList) {
                return self::$headerList;
            }
            $headers = [];
Severity: Minor
Found in src/Edde/Common/Http/HeaderList.php - About 1 hr to fix

Method convert has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function convert($content, string $mime, string $target = null): IContent {
            switch ($mime) {
                /** @noinspection PhpMissingBreakStatementInspection */
                case 'stream+application/json':
                    $content = file_get_contents($content);
Severity: Minor
Found in src/Edde/Ext/Converter/JsonConverter.php - About 1 hr to fix

Method getTagList has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function getTagList(): array {
            return [
                'html',
                'head',
                'meta',
Severity: Minor
Found in src/Edde/Common/Html/Html5Generator.php - About 1 hr to fix

Function tick has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        public function tick() {
            $connectionList = $ignore = $readList = array_map(function (IConnection $connection) {
                return $connection->getStream();
            }, $this->connectionList);
            if (($select = stream_select($readList, $ignore, $ignore, 3)) === false) {
Severity: Minor
Found in src/Edde/Common/Stream/StreamServer.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 handleSetup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        protected function handleSetup() {
            parent::handleSetup();
            $cache = $this->cache();
            if (($this->translationList = $cache->load($cacheId = implode(',', array_keys($this->fileList)))) === null) {
                foreach ($this->fileList as $file) {
Severity: Minor
Found in src/Edde/Common/Translator/Dictionary/CsvDictionary.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 match has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        static public function match(string $string, string $pattern, bool $named = false, bool $trim = false) {
            $match = null;
            $match = self::pcre('preg_match', [
                $pattern,
                $string,
Severity: Minor
Found in src/Edde/Common/Strings/StringUtils.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 mime has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        static public function mime(string $file) {
            if (is_file($file) === false) {
                throw new FileException(sprintf('The given file [%s] is not a file.', $file));
            }
            $url = Url::create($file);
Severity: Minor
Found in src/Edde/Common/File/FileUtils.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 onEnter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        protected function onEnter(INode $node, \Iterator $iterator, ...$parameters) {
            switch ($node->getName()) {
                case 'minify-css':
                    if ($this->minify) {
                        throw new MacroException(sprintf('Css minify does not support recursion.'));
Severity: Minor
Found in src/Edde/Ext/Template/Macro/CssMacro.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 onEnter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        protected function onEnter(INode $node, \Iterator $iterator, ...$parameters) {
            switch ($node->getName()) {
                case 'minify-js':
                    if ($this->minify) {
                        throw new MacroException(sprintf('Js minify does not support recursion.'));
Severity: Minor
Found in src/Edde/Ext/Template/Macro/JsMacro.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 createSchema has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function createSchema(INode $node): ISchema {
            $schema = new Schema($node->getName(), $node->getAttribute('namespace'));
            $schema->setMetaList($node->getMetaList()->array());
            $magic = $schema->getMeta('magic', true);
            foreach ($this->propertyListNodeQuery->filter($node) as $propertyNode) {
Severity: Minor
Found in src/Edde/Common/Schema/SchemaManager.php - About 1 hr to fix

Method handleSetup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function handleSetup() {
            parent::handleSetup();
            if (empty($this->schemaLoaderList)) {
                throw new SchemaManagerException(sprintf('There are no schema loaders in [%s].', static::class));
            }
Severity: Minor
Found in src/Edde/Common/Schema/SchemaManager.php - About 1 hr to fix

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

        static public function toAscii(string $string): string {
            $string = preg_replace('~[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]~u', '', $string);
            $string = strtr($string, '`\'"^~?', "\x01\x02\x03\x04\x05\x06");
            $string = str_replace([
                "\xE2\x80\x9E",
Severity: Minor
Found in src/Edde/Common/Strings/StringUtils.php - About 1 hr to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                if (isset(self::$cache[$cacheId = 'property/' . (is_object($object) ? get_class($object) : $object) . $property]) === false) {
                    $reflectionClass = new ReflectionClass($object);
                    self::$cache[$cacheId] = $reflectionProperty = $reflectionClass->getProperty($property);
                    $reflectionProperty->setAccessible(true);
                }
Severity: Major
Found in src/Edde/Common/Reflection/ReflectionUtils.php and 1 other location - About 1 hr to fix
src/Edde/Common/Reflection/ReflectionUtils.php on lines 62..66

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 103.

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                if (isset(self::$cache[$cacheId = 'property/' . (is_object($object) ? get_class($object) : $object) . $property]) === false) {
                    $reflectionClass = new ReflectionClass($object);
                    self::$cache[$cacheId] = $reflectionProperty = $reflectionClass->getProperty($property);
                    $reflectionProperty->setAccessible(true);
                }
Severity: Major
Found in src/Edde/Common/Reflection/ReflectionUtils.php and 1 other location - About 1 hr to fix
src/Edde/Common/Reflection/ReflectionUtils.php on lines 40..44

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 103.

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

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

        static public function matchAll(string $string, string $pattern, bool $named = false, $trim = false): array {
            $match = null;
            $match = self::pcre('preg_match_all', [
                $pattern,
                $string,
Severity: Minor
Found in src/Edde/Common/Strings/StringUtils.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 accept has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        static public function accept(string $accept = null): array {
            if ($accept === null) {
                return ['*/*'];
            }
            $accepts = [];
Severity: Minor
Found in src/Edde/Common/Http/HttpUtils.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 language has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        static public function language(string $language = null, string $default = 'en'): array {
            if ($language === null) {
                return [$default];
            }
            foreach (explode(',', $language) as $part) {
Severity: Minor
Found in src/Edde/Common/Http/HttpUtils.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 onExecute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        public function onExecute(IElement $element) {
            foreach ($this->requestHandlerList as $requestHandler) {
                /** @var $response IElement */
                if ($requestHandler->canHandle($element)) {
                    if (($response = $requestHandler->execute($element)) !== null && $response instanceof IElement) {
Severity: Minor
Found in src/Edde/Common/Protocol/Request/RequestService.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 charset has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        static public function charset(string $charset = null, $default = 'utf-8'): array {
            if ($charset === null) {
                return [$default];
            }
            foreach (explode(',', $charset) as $part) {
Severity: Minor
Found in src/Edde/Common/Http/HttpUtils.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 content has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        public function content(IContent $content, array $targetList = null): IConvertable {
            $exception = null;
            $unknown = true;
            $mime = $content->getMime();
            foreach ($targetList ?? [] as $target) {
Severity: Minor
Found in src/Edde/Common/Converter/ConverterManager.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

Severity
Category
Status
Source
Language