luyadev/luya

View on GitHub

Showing 82 of 90 total issues

Function getThemes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getThemes($throwException = false)
    {
        if ($this->_themes) {
            return $this->_themes;
        }
Severity: Minor
Found in core/theme/ThemeManager.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 timeToIso8601Duration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function timeToIso8601Duration($time)
    {
        $units = [
            "Y" => 365 * 24 * 3600,
            "D" =>     24 * 3600,
Severity: Minor
Found in core/web/jsonld/DurationValue.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 logValueToTable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function logValueToTable(array $logs)
    {
        $table = new Table();
        $table->setHeaders(['Key', 'Value']);
        $rows = [];
Severity: Minor
Found in core/console/commands/ImportController.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 getExceptionArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getExceptionArray($exception)
    {
        $_message = 'Uknonwn exception object, not instance of \Exception.';
        $_file = 'unknown';
        $_line = 0;
Severity: Minor
Found in core/traits/ErrorHandlerTrait.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 addRules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addRules($rules, $append = true)
    {
        foreach ($rules as $key => $rule) {
            if (is_array($rule) && isset($rule['composition'])) {
                foreach ($rule['composition'] as $composition => $pattern) {
Severity: Minor
Found in core/web/UrlManager.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 actionAdd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionAdd($repo, $filename, $language = "*")
    {
        $repoPath = "repos/$repo";
        $messageFiles = glob("$repoPath/src/**/messages/$language/$filename.php") ?: glob("$repoPath/src/messages/$language/$filename.php");

Severity: Minor
Found in dev/TranslationController.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 getControllers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getControllers(Module $module)
    {
        $files = [];

        try { // https://github.com/yiisoft/yii2/blob/master/framework/base/Module.php#L253
Severity: Minor
Found in core/helpers/ObjectHelper.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function run($app)
    {
        foreach ($app->getApplicationModules() as $id => $module) {
            $folder = $module->basePath . DIRECTORY_SEPARATOR . 'commands';
            if (file_exists($folder) && is_dir($folder)) {
Severity: Minor
Found in core/console/Bootstrap.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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function init()
    {
        $path = Yii::getAlias($this->configFile);
        if (file_exists($path)) {
            $config = (include($path));
Severity: Minor
Found in core/web/Element.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 actionCreate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionCreate()
    {
        Console::clearScreenBeforeCursor();

        $moduleName = $this->prompt("Enter the name of the module you like to generate:");
Severity: Minor
Found in core/console/commands/ModuleController.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 parseRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseRequest($request)
    {
        // extra data from request to composition, which changes the pathInfo of the Request-Object.
        $resolver = $this->getComposition()->getResolvedPathInfo($request);

Severity: Minor
Found in core/web/UrlManager.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

Avoid too many return statements within this method.
Open

            return $model->addError($attribute, Yii::t('luya', '{attribute} must include at least one uppercase letter.', ['attribute' => $model->getAttributeLabel($attribute)]));
Severity: Major
Found in core/validators/StrengthValidator.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return $model->addError($attribute, Yii::t('luya', '{attribute} must include at least one lowercase letter.', ['attribute' => $model->getAttributeLabel($attribute)]));
    Severity: Major
    Found in core/validators/StrengthValidator.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return $this->outputSuccess("Theme files has been created successfully. Please run `".$_SERVER['PHP_SELF']." import` to import the theme into the database.");
      Severity: Major
      Found in core/console/commands/ThemeController.php - About 30 mins to fix

        Function callMethodSanitizeArguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function callMethodSanitizeArguments($object, $method, array $argumentsList = [])
            {
                // get class reflection object
                $reflection = new ReflectionMethod($object, $method);
                // array where the sanitized arguemnts will be stored
        Severity: Minor
        Found in core/helpers/ObjectHelper.php - About 25 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 getRequestRoute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getRequestRoute()
            {
                if ($this->_requestRoute !== null) {
                    return $this->_requestRoute;
                }
        Severity: Minor
        Found in core/base/ModuleReflection.php - About 25 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 startModules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function startModules($app)
            {
                foreach ($this->getModules() as $id => $module) {
                    // set an alias for all user modules
                    Yii::setAlias('@'.$id, $module->getBasePath());
        Severity: Minor
        Found in core/base/BaseBootstrap.php - About 25 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 resolveRoute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function resolveRoute($route)
            {
                $routeParts = explode('/', $route);
                foreach ($routeParts as $k => $v) {
                    if (($k == 0 && $v == $this->id) || (empty($v))) {
        Severity: Minor
        Found in core/base/Module.php - About 25 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 getMailer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getMailer()
            {
                if ($this->_mailer === null) {
                    $this->_mailer = new PHPMailer();
                    $this->_mailer->CharSet = 'UTF-8';
        Severity: Minor
        Found in core/components/Mail.php - About 25 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 applicationConsole has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function applicationConsole()
            {
                $this->setIsCli(true);
                $config = $this->getConfigArray();
                $config['defaultRoute'] = 'help';
        Severity: Minor
        Found in core/base/Boot.php - About 25 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