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.

AssertUnchanged   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 27.03 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 10
loc 37
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureVariables() 10 10 1
A assemble() 0 12 1

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
 * See class comment
4
 *
5
 * PHP Version 5
6
 *
7
 * @category   Netresearch
8
 * @package    Netresearch\Kite\Workflow
9
 * @subpackage Git
10
 * @author     Christian Opitz <[email protected]>
11
 * @license    http://www.netresearch.de Netresearch Copyright
12
 * @link       http://www.netresearch.de
13
 */
14
15
namespace Netresearch\Kite\Workflow\Git;
16
use Netresearch\Kite\Workflow;
17
18
/**
19
 * Workflow to assert a git repo has no uncommited and unpushed changes
20
 *
21
 * @category   Netresearch
22
 * @package    Netresearch\Kite\Workflow
23
 * @subpackage Git
24
 * @author     Christian Opitz <[email protected]>
25
 * @license    http://www.netresearch.de Netresearch Copyright
26
 * @link       http://www.netresearch.de
27
 */
28
class AssertUnchanged extends Workflow
29
{
30
    /**
31
     * Variable configuration
32
     *
33
     * @return array
34
     */
35 View Code Duplication
    protected function configureVariables()
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...
36
    {
37
        return array(
38
            'cwd' => array(
39
                'type' => 'string',
40
                'label' => 'The directory to change into'
41
            ),
42
            '--'
43
        ) + parent::configureVariables();
44
    }
45
46
47
    /**
48
     * Assemble the tasks
49
     *
50
     * @return void
51
     */
52
    public function assemble()
53
    {
54
        $cwd = $this->get('cwd');
55
56
        $this
57
            ->tryCatch('Detected unstaged changes - please commit or stash them first')
58
            ->git('diff-index', $cwd, array('quiet' => true, 'HEAD', '--'));
59
60
        $this
61
            ->tryCatch('Your branch is not in sync with the remote tracking branch')
62
            ->shell("test -z \"$(git status -u no | grep -E '[^'\''](ahead|behind|diverged)[^'\'']')\"", $cwd);
63
    }
64
}
65
?>
66