phpmentoring/webapp

View on GitHub

Showing 23 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

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

        public function getMentorsAction(Application $app)
        {
            /** @var \Mentoring\User\UserService $userService */
            $userService = $app['user.manager'];
    
    
    Severity: Major
    Found in src/Mentoring/PublicSite/Controller/ApiController.php and 1 other location - About 2 hrs to fix
    src/Mentoring/PublicSite/Controller/ApiController.php on lines 13..29

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

    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

        public function getApprenticesAction(Application $app)
        {
            /** @var \Mentoring\User\UserService $userService */
            $userService = $app['user.manager'];
    
    
    Severity: Major
    Found in src/Mentoring/PublicSite/Controller/ApiController.php and 1 other location - About 2 hrs to fix
    src/Mentoring/PublicSite/Controller/ApiController.php on lines 31..47

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

    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 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
                                Severity
                                Category
                                Status
                                Source
                                Language