phpmentoring/webapp

View on GitHub

Showing 21 of 23 total issues

User has 36 functions (exceeds 20 allowed). Consider refactoring.
Open

class User
{
    protected $id;
    protected $email;
    protected $roles = [];
Severity: Minor
Found in src/Mentoring/User/User.php - About 4 hrs to fix

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

        public function extract(User $object)
        {
            $data = [
                'email' => $object->getEmail(),
                'id' => $object->getId(),
    Severity: Minor
    Found in src/Mentoring/User/UserHydrator.php - About 1 hr to fix

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

          public function hydrate(array $data, User $object)
          {
              $object->setEmail($data['email']);
              $object->setName($data['name']);
              $object->setSendNotifications($data['sendNotifications']);
      Severity: Minor
      Found in src/Mentoring/User/UserHydrator.php - About 1 hr to fix

        Method buildForm has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function buildForm(FormBuilderInterface $builder, array $options)
            {
                $mentorTags = $builder
                    ->create('mentorTags', TextType::class, [
                            'required' => false,
        Severity: Minor
        Found in src/Mentoring/Account/Form/ProfileForm.php - About 1 hr to fix

          Method githubAction has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function githubAction(Application $app, Request $request)
              {
                  $clientID = $app['config']['github']['api_key'];
                  $clientSecret = $app['config']['github']['api_secret'];
                  $code = $request->query->get('code');
          Severity: Minor
          Found in src/Mentoring/Auth/Controller/AuthController.php - About 1 hr to fix

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

                public function hydrate(array $data, User $object)
                {
                    $object->setEmail($data['email']);
                    $object->setName($data['name']);
                    $object->setSendNotifications($data['sendNotifications']);
            Severity: Minor
            Found in src/Mentoring/User/UserHydrator.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 githubAction has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                public function githubAction(Application $app, Request $request)
                {
                    $clientID = $app['config']['github']['api_key'];
                    $clientSecret = $app['config']['github']['api_secret'];
                    $code = $request->query->get('code');
            Severity: Minor
            Found in src/Mentoring/Auth/Controller/AuthController.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 testSettersAndGetters has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function testSettersAndGetters()
                {
                    $testData = [
                        'email' => 'test@test.com',
                        'githubUid' => '1234',
            Severity: Minor
            Found in tests/MentoringTest/User/UserTest.php - About 1 hr to fix

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

                  protected function execute(InputInterface $input, OutputInterface $output)
                  {
                      $output->writeln('Starting to fetch github-Usernames');
                      $data = parse_ini_file(__DIR__ . '/../../../.env');
                      $pdo = new \PDO(
              Severity: Minor
              Found in src/Mentoring/Command/AddMissingGithubUsernamesCommand.php - About 1 hr to fix

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

                    public function up()
                    {
                        $taxonomyVocabulary = $this->table('taxonomyVocabulary');
                        $taxonomyVocabulary
                            ->addColumn('name', 'string')
                Severity: Minor
                Found in data/migrations/20150507031216_add_tags_table.php - About 1 hr to fix

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

                      public function save(Conversation $conversation)
                      {
                          $convo_data = [
                              'id' => $conversation->getId(),
                              'from_user_id' => $conversation->getFromUser()->getId(),
                  Severity: Minor
                  Found in src/Mentoring/Conversation/ConversationRepository.php - About 1 hr to fix

                    Method hydrateConversation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function hydrateConversation(array $convo_data)
                        {
                            $messages_data = $this->dbal->fetchAll(
                                'SELECT * FROM messages WHERE conversation_id = :conversation_id',
                                ['conversation_id' => $convo_data['id']]
                    Severity: Minor
                    Found in src/Mentoring/Conversation/ConversationRepository.php - About 1 hr to fix

                      Method getTerms has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getTerms(Application $app, $vocabularyName, $termName = null)
                          {
                              /** @var \Mentoring\Taxonomy\TaxonomyService $taxonomyService */
                              $taxonomyService = $app['taxonomy.service'];
                              try {
                      Severity: Minor
                      Found in src/Mentoring/PublicSite/Controller/ApiController.php - About 1 hr to fix

                        Method register has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function register(Container $app)
                            {
                                $app['conversation_repository'] = function (Application $app) {
                                    return new ConversationRepository($app['db'], $app['user.manager']);
                                };

                          Function extract has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function extract(User $object)
                              {
                                  $data = [
                                      'email' => $object->getEmail(),
                                      'id' => $object->getId(),
                          Severity: Minor
                          Found in src/Mentoring/User/UserHydrator.php - About 55 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

                          Method startNew has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              public static function startNew(User $fromUser, User $toUser, $subject, $opening_body, \DateTime $created_at = null)
                          Severity: Minor
                          Found in src/Mentoring/Conversation/Conversation.php - About 35 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return $types;

                              Avoid too many return statements within this method.
                              Open

                                          return new AuthController();
                              Severity: Major
                              Found in src/Mentoring/Auth/ServiceProvider/AuthServiceProvider.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return new ConversationReplyForm();

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

                                      public function save(Conversation $conversation)
                                      {
                                          $convo_data = [
                                              'id' => $conversation->getId(),
                                              'from_user_id' => $conversation->getFromUser()->getId(),
                                  Severity: Minor
                                  Found in src/Mentoring/Conversation/ConversationRepository.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