vijos/openvj

View on GitHub

Showing 76 of 103 total issues

File CommentUtil.php has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This file is part of openvj project.
 *
 * Copyright 2013-2015 openvj dev team.
Severity: Minor
Found in src/Comment/CommentUtil.php - About 5 hrs to fix

    Function contains has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        public function contains($text, $cacheKey, callable $miss)
        {
            $value = $this->redis->hget($this->prefix, $cacheKey);
            if ($value === false) {
                // Haven't found data in the cache, we need to build the tree
    Severity: Minor
    Found in src/Security/KeywordFilter.php - About 3 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 execute has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function execute(InputInterface $input, OutputInterface $output)
        {
            $helper = $this->getHelper('question');
    
            // ask fields
    Severity: Major
    Found in tools/CertificateGenerateCommand.php - About 3 hrs to fix

      File Application.php has 313 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * This file is part of openvj project.
       *
       * Copyright 2013-2015 openvj dev team.
      Severity: Minor
      Found in src/Core/Application.php - About 3 hrs to fix

        Method createUser has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function createUser($username, $password, $email)
            {
                if (!is_string($username)) {
                    throw new InvalidArgumentException('username', 'type_invalid');
                }
        Severity: Major
        Found in src/User/UserManager.php - About 3 hrs to fix

          Function initService has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function initService()
              {
                  $services = self::$resources['service'];
                  foreach ($services as $service_name => $service_config) {
                      self::set($service_name, function () use ($service_config) {
          Severity: Minor
          Found in src/Core/Application.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 import has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function import(callable $progress = null)
              {
                  if (Application::coll('User')->count() > 0) {
                      throw new UserException('User.Importer.VijosImporter.userCollectionNotEmpty');
                  }
          Severity: Major
          Found in src/User/Importer/VijosImporter.php - About 2 hrs to fix

            Method joinDomainById has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function joinDomainById($uid, \MongoId $domainId)
                {
                    if (!Validator::int()->validate($uid)) {
                        throw new InvalidArgumentException('uid', 'type_invalid');
                    }
            Severity: Major
            Found in src/User/DomainManager.php - About 2 hrs to fix

              Method createReply has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function createReply(\MongoId $commentId, $ref, $owner, $markdown)
                  {
                      if (!is_string($ref)) {
                          throw new InvalidArgumentException('ref', 'type_invalid');
                      }
              Severity: Major
              Found in src/Comment/CommentUtil.php - About 2 hrs to fix

                Method generate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function generate($purpose, $identifier, $expireAt, $data = null, $length = 30)
                    {
                        if (!is_string($purpose)) {
                            throw new InvalidArgumentException('purpose', 'type_invalid');
                        }
                Severity: Major
                Found in src/Security/TokenManager.php - About 2 hrs to fix

                  Method modifyReply has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function modifyReply(\MongoId $commentId, $ref, \MongoId $replyId, $markdown)
                      {
                          if (!is_string($ref)) {
                              throw new InvalidArgumentException('ref', 'type_invalid');
                          }
                  Severity: Minor
                  Found in src/Comment/CommentUtil.php - About 1 hr to fix

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

                        public static function modifyContent(\MongoId $pid, $uid, $markdown)
                        {
                            if (!Validator::int()->validate($uid)) {
                                throw new InvalidArgumentException('uid', 'type_invalid');
                            }
                    Severity: Minor
                    Found in src/Problem/ProblemUtil.php - About 1 hr to fix

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

                          public static function createProblem($uid, $title, array $visibleDomains)
                          {
                              if (!Validator::int()->validate($uid)) {
                                  throw new InvalidArgumentException('uid', 'type_invalid');
                              }
                      Severity: Minor
                      Found in src/Problem/ProblemUtil.php - About 1 hr to fix

                        Method modifyMeta has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function modifyMeta(\MongoId $pid, $title, array $tags, array $visibleDomains)
                            {
                                if (!is_string($title)) {
                                    throw new InvalidArgumentException('title', 'type_invalid');
                                }
                        Severity: Minor
                        Found in src/Problem/ProblemUtil.php - About 1 hr to fix

                          Function route has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function route()
                              {
                                  $dispatcher = Application::get('dispatcher');
                                  $request = Application::get('request');
                                  $response = Application::get('response');
                          Severity: Minor
                          Found in src/Core/RouteTrait.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 createComment has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function createComment($ref, $owner, $markdown)
                              {
                                  if (!is_string($ref)) {
                                      throw new InvalidArgumentException('ref', 'type_invalid');
                                  }
                          Severity: Minor
                          Found in src/Comment/CommentUtil.php - About 1 hr to fix

                            Method contains has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function contains($text, $cacheKey, callable $miss)
                                {
                                    $value = $this->redis->hget($this->prefix, $cacheKey);
                                    if ($value === false) {
                                        // Haven't found data in the cache, we need to build the tree
                            Severity: Minor
                            Found in src/Security/KeywordFilter.php - About 1 hr to fix

                              Method modifyComment has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function modifyComment(\MongoId $commentId, $ref, $markdown)
                                  {
                                      if (!is_string($ref)) {
                                          throw new InvalidArgumentException('ref', 'type_invalid');
                                      }
                              Severity: Minor
                              Found in src/Comment/CommentUtil.php - About 1 hr to fix

                                Method createRole has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static function createRole($name, $internal = false, \MongoId $domain = null, $owner = null)
                                    {
                                        if (!is_string($name)) {
                                            throw new InvalidArgumentException('name', 'type_invalid');
                                        }
                                Severity: Minor
                                Found in src/User/RoleManager.php - About 1 hr to fix

                                  Method createDiscussion has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public static function createDiscussion(\MongoId $topicId, $owner, $title, $markdown)
                                      {
                                          if (!Validator::int()->validate($owner)) {
                                              throw new InvalidArgumentException('owner', 'type_invalid');
                                          }
                                  Severity: Minor
                                  Found in src/Discussion/DiscussionUtil.php - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language