hauntd/help-center

View on GitHub

Showing 276 of 276 total issues

Function init has 123 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    init: function() {
        this.treeElement = $('#category-list');
        if (!this.treeElement.length) {
            return false;
        }
Severity: Major
Found in modules/management/assets/static/js/management-categories.js - About 4 hrs to fix

    The class User has 13 public methods. Consider refactoring User to keep number of public methods under 10.
    Open

    class User extends ActiveRecord implements IdentityInterface
    {
        const STATUS_DELETED = 0;
        const STATUS_ACTIVE = 10;
    
    
    Severity: Minor
    Found in models/User.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

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

    <?php
    
    /* @var $this yii\web\View */
    /* @var $form yii\bootstrap\ActiveForm */
    /* @var $model app\forms\PasswordResetRequestForm */
    Severity: Major
    Found in views/site/requestPasswordResetToken.php and 1 other location - About 2 hrs to fix
    views/site/resetPassword.php on lines 1..28

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

    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

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

    <?php
    
    /* @var $this yii\web\View */
    /* @var $form yii\bootstrap\ActiveForm */
    /* @var $model app\forms\ResetPasswordForm */
    Severity: Major
    Found in views/site/resetPassword.php and 1 other location - About 2 hrs to fix
    views/site/requestPasswordResetToken.php on lines 1..28

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

    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 display has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        display: function() {
            var options = {
                dragAndDrop: true,
                selectable: true,
                autoOpen: true,
    Severity: Major
    Found in modules/management/assets/static/js/management-categories.js - About 2 hrs to fix

      Function performModelSave has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function performModelSave(ActiveRecord $model, array $params)
          {
              $ajax = Yii::$app->request->isAjax;
              if ($model->save()) {
                  if ($ajax) {
      Severity: Minor
      Found in modules/management/controllers/ManagementController.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

      Method actionIndex has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionIndex()
          {
              if (!$this->confirm('Remove all data and insert demo data?')) {
                  return false;
              }
      Severity: Minor
      Found in commands/DataController.php - About 1 hr to fix

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

        <?php
        defined('YII_DEBUG') or define('YII_DEBUG', true);
        defined('YII_ENV') or define('YII_ENV', 'dev');
        
        require(__DIR__ . '/../vendor/autoload.php');
        Severity: Major
        Found in environments/prod/web/index.php and 1 other location - About 1 hr to fix
        environments/dev/web/index.php on lines 1..15

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

        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

        <?php
        
        defined('YII_DEBUG') or define('YII_DEBUG', true);
        defined('YII_ENV') or define('YII_ENV', 'dev');
        
        
        Severity: Major
        Found in environments/dev/web/index.php and 1 other location - About 1 hr to fix
        environments/prod/web/index.php on lines 1..14

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

        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

        Method safeUp has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function safeUp()
            {
                $this->createTable('{{%user}}', [
                    'id' => $this->primaryKey(),
                    'username' => $this->string()->notNull()->unique(),
        Severity: Minor
        Found in migrations/m160225_083657_init.php - About 1 hr to fix

          Function exports has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function (grunt) {
              grunt.initConfig({
                  less: {
                      prod: {
                          options: {
          Severity: Minor
          Found in Gruntfile.js - About 1 hr to fix

            Avoid excessively long variable names like $rootCategoryWrapperClass. Keep variable name length under 20.
            Open

                public $rootCategoryWrapperClass;
            Severity: Minor
            Found in widgets/CategoriesWidget.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Function matchRole has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function matchRole($user)
                {
                    if (empty($this->roles)) {
                        return true;
                    }
            Severity: Minor
            Found in components/AccessRule.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 renderItems has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function renderItems()
                {
                    $items = [];
                    foreach ($this->items as $i => $item) {
                        if ($item instanceof NavItemInterface) {
            Severity: Minor
            Found in widgets/navigation/Nav.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 renderCategories has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                private function renderCategories($categories, $parentId = null, $level = 0)
                {
                    $html = '';
            
                    foreach ($categories as $category) {
            Severity: Minor
            Found in widgets/CategoriesWidget.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

            Avoid using short method names like Module::t(). The configured minimum method name length is 3.
            Open

                public static function t($category, $message, $params = [], $language = null)
                {
                    return Yii::t('modules/management/' . $category, $message, $params, $language);
                }
            Severity: Minor
            Found in modules/management/Module.php by phpmd

            ShortMethodName

            Since: 0.2

            Detects when very short method names are used.

            Example

            class ShortMethod {
                public function a( $index ) { // Violation
                }
            }

            Source https://phpmd.org/rules/naming.html#shortmethodname

            Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function run()
                {
                    if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
                        // action has been invoked not from error handler, but by direct route, so we display '404 Not Found'
                        $exception = new HttpException(404, Yii::t('yii', 'Page not found.'));
            Severity: Minor
            Found in actions/ErrorAction.php - About 1 hr to fix

              Function onCreateLi has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          onCreateLi: function(node, li) {
                              if (node.isEmpty) {
                                  li.addClass('jqtree-empty');
                                  return;
                              }
              Severity: Minor
              Found in modules/management/assets/static/js/management-categories.js - About 1 hr to fix

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

                    public function performModelSave(ActiveRecord $model, array $params)
                    {
                        $ajax = Yii::$app->request->isAjax;
                        if ($model->save()) {
                            if ($ajax) {
                Severity: Minor
                Found in modules/management/controllers/ManagementController.php - About 1 hr to fix

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

                              <?= $this->render('_form', [
                                  'user' => $user,
                                  'helper' => $helper,
                                  'formId' => 'user-update-form',
                                  'buttons' => [
                  Severity: Major
                  Found in modules/management/views/user/update.php and 1 other location - About 1 hr to fix
                  modules/management/views/post/update.php on lines 20..34

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language