vijos/openvj

View on GitHub

Showing 76 of 103 total issues

Method initConfig has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function initConfig()
    {
        if (file_exists(self::$CONFIG_DIRECTORY . '/config.yml')) {
            // config file exists
            $cachePath = self::$CACHE_DIRECTORY . '/config.php';
Severity: Minor
Found in src/Core/Application.php - About 1 hr to fix

    Method route has 40 lines of code (exceeds 25 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

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

          public function onEvent(GenericEvent $event, $eventName, $dispatchStatus, array $dispatchHandler = null)
          {
              if ($dispatchStatus == Dispatcher::FOUND) {
                  if (isset($dispatchHandler['csrf']) && $dispatchHandler['csrf'] === true) {
                      $csrfToken = $this->request->headers->get('csrfToken');
      Severity: Minor
      Found in src/EventListener/CsrfTokenCheckingService.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 verify has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function verify($password, $salt, $hash)
          {
              $component = explode('|', $hash);
              if (count($component) < 2) {
                  return false;
      Severity: Minor
      Found in src/User/PasswordEncoder.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 createUser has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function createUser($username, $password, $email)
          {
              if (!is_string($username)) {
                  throw new InvalidArgumentException('username', 'type_invalid');
              }
      Severity: Minor
      Found in src/User/UserManager.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 generate has a Cognitive Complexity of 13 (exceeds 5 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: Minor
      Found in src/Security/TokenManager.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 testCheckCookieTokenCredentialInvalid has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function testCheckCookieTokenCredentialInvalid()
          {
      
              // null
              $throw = false;
      Severity: Minor
      Found in src/Test/User/UserCredentialTest.php - About 1 hr to fix

        Function onEvent has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function onEvent(GenericEvent $event, $eventName)
            {
                if (stripos($this->request->getRequestUri(), '.asp') !== false) {
                    $ua = $this->request->getUserAgent();
                    if (
        Severity: Minor
        Found in src/EventListener/VJRedirectionService.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 createRole has a Cognitive Complexity of 12 (exceeds 5 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

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

            public function testAppendLog()
            {
                $cases = [
                    [
                        'type' => VJ::LOGIN_TYPE_FAILED_WRONG_PASSWORD,
        Severity: Minor
        Found in src/Test/EventListener/LoginLogServiceTest.php - About 1 hr to fix

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

              public function handle()
              {
                  if (!$this->isAjaxRequest()) {
                      return Handler::DONE;
                  }
          Severity: Minor
          Found in src/Core/ExceptionHandler/JsonResponseHandler.php - About 1 hr to fix

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

                protected function execute(InputInterface $input, OutputInterface $output)
                {
                    $helper = $this->getHelper('question');
            
                    if ($input->getOption('type') !== 'vijos') {
            Severity: Minor
            Found in tools/UserImportCommand.php - About 1 hr to fix

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

                  protected function execute(InputInterface $input, OutputInterface $output)
                  {
                      $output->writeln('Rebuilding indexes...');
              
                      Application::coll('System')->deleteIndexes();
              Severity: Minor
              Found in tools/IndexRebuildCommand.php - About 1 hr to fix

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

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

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

                      public static function removeUrlUnsafeChar($str)
                      {
                          $str = preg_replace('/\s/g', '', $str);
                          $str = str_replace([
                              '&',
                  Severity: Minor
                  Found in src/VJ.php - About 1 hr to fix

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

                        public function __construct($category, $subCategory = null)
                        {
                            if (!is_string($category)) {
                                throw new InvalidArgumentException('category', 'type_invalid');
                            }
                    Severity: Minor
                    Found in src/Problem/Tag/CategoryTag.php - About 1 hr to fix

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

                          public function import(callable $progress = null)
                          {
                              if (Application::coll('User')->count() > 0) {
                                  throw new UserException('User.Importer.VijosImporter.userCollectionNotEmpty');
                              }
                      Severity: Minor
                      Found in src/User/Importer/VijosImporter.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 modifyMeta has a Cognitive Complexity of 11 (exceeds 5 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

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

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

                        Method onEvent has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function onEvent(GenericEvent $event, $eventName)
                            {
                                if (stripos($this->request->getRequestUri(), '.asp') !== false) {
                                    $ua = $this->request->getUserAgent();
                                    if (
                        Severity: Minor
                        Found in src/EventListener/VJRedirectionService.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language