GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 23c71a...dcb9a9 )
by Richard
11:04
created

DefaultController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 39.39 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 26
loc 66
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 9 1
A songSearchAction() 0 6 1
A defaultViewParams() 0 16 1
B announceAction() 26 26 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Phase\TakeATicketBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
7
8
class DefaultController extends BaseController
9
{
10
    public function indexAction()
11
    {
12
        $viewParams = $this->defaultViewParams();
13
        $viewParams['freeze'] = $this->getDataStore()->getSetting('freeze');
14
        $viewParams['freezeMessage'] = $this->getDataStore()->getSetting('freezeMessage');
15
16
        // replace this example code with whatever you need
17
        return $this->render('default/upcoming.html.twig', $viewParams);
18
    }
19
20
    public function songSearchAction()
21
    {
22
        $viewParams = $this->defaultViewParams();
23
        $viewParams['freeze'] = $this->getDataStore()->getSetting('freeze');
24
        return $this->render('default/songSearch.html.twig', $viewParams);
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    protected function defaultViewParams()
31
    {
32
        //$protocol = $_SERVER['HTTPS'] ? 'https' : 'http';
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
        $protocol = 'http'; // $_SERVER['HTTPS'] ? 'https' : 'http';
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
        /**
35
 * @noinspection RealpathInSteamContextInspection
36
*/
37
        $viewParams = [
38
            //'serverInfo' => $protocol . '://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . '/',
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
            'serverInfo' => $protocol.'://127.0.0.1:8000/', //FIXME get server name (from config if not in request?)
40
            'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),
41
        ];
42
        $viewParams['displayOptions'] = $this->getDisplayOptions();
43
44
        return $viewParams;
45
    }
46
47 View Code Duplication
    public function announceAction($section)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $rootDir = realpath(__DIR__.'/../../../../');
50
        $announceDir = $rootDir.'/docs/announcements';
51
52
        if (!preg_match('/^\w+$/', $section)) {
53
            throw new NotFoundHttpException(); // don't give access to anything but plain names
54
        }
55
56
        $candidateFile = $announceDir.'/'.$section.'.md';
57
58
        if (!file_exists($candidateFile)) {
59
            throw new NotFoundHttpException();
60
        }
61
62
        $markdown = file_get_contents($candidateFile);
63
64
        return $this->render(
65
            ':default:announce.html.twig',
66
            [
67
                'announcement' => $markdown,
68
                'messageClass' => $section,
69
                'displayOptions' => $this->getDisplayOptions(),
70
            ]
71
        );
72
    }
73
}
74