Failed Conditions
Push — master ( a46fbb...c35fd9 )
by Alexander
01:13
created

FunctionCommentUnitTest::getErrorList()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 108

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 108
rs 8
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * CodingStandard_Tests_Commenting_FunctionCommentUnitTest.
4
 *
5
 * PHP version 5
6
 *
7
 * @category PHP
8
 * @package  PHP_CodeSniffer
9
 * @author   Greg Sherwood <[email protected]>
10
 * @author   Marc McIntyre <[email protected]>
11
 * @author   Alexander Obuhovich <[email protected]>
12
 * @license  https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause
13
 * @link     https://github.com/aik099/CodingStandard
14
 */
15
16
namespace CodingStandard\Tests\Commenting;
17
18
use TestSuite\AbstractSniffUnitTest;
19
20
/**
21
 * Unit test class for FunctionCommentSniff.
22
 *
23
 * @category PHP
24
 * @package  PHP_CodeSniffer
25
 * @author   Greg Sherwood <[email protected]>
26
 * @author   Marc McIntyre <[email protected]>
27
 * @author   Alexander Obuhovich <[email protected]>
28
 * @license  https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause
29
 * @link     https://github.com/aik099/CodingStandard
30
 */
31
class FunctionCommentUnitTest extends AbstractSniffUnitTest
32
{
33
34
    /**
35
     * Returns the lines where errors should occur.
36
     *
37
     * The key of the array should represent the line number and the value
38
     * should represent the number of errors that should occur on that line.
39
     *
40
     * @param string $testFile Name of the file with test data.
41
     *
42
     * @return array(int => int)
43
     */
44
    public function getErrorList($testFile)
45
    {
46
        if ($testFile === 'FunctionCommentUnitTest.1.inc') {
47
            $ret = array(
48
                    5   => 1,
49
                    6   => 1,
50
                    10  => 3,
51
                    12  => 2,
52
                    13  => 2,
53
                    14  => 1,
54
                    15  => 2, // +1 for "excessive @throws" tag.
55
                    28  => 1,
56
                    43  => 1,
57
                    52  => 1,
58
                    76  => 1,
59
                    87  => 1,
60
                    103 => 1,
61
                    109 => 1,
62
                    110 => 1,
63
                    112 => 1,
64
                    122 => 1,
65
                    123 => 3,
66
                    124 => 2,
67
                    125 => 1,
68
                    126 => 1,
69
                    137 => 4,
70
                    138 => 4,
71
                    139 => 4,
72
                    143 => 2,
73
                    152 => 1,
74
                    155 => 2,
75
                    159 => 1,
76
                    166 => 1,
77
                    173 => 1,
78
                    180 => 1,
79
                    183 => 1,
80
                    190 => 2,
81
                    193 => 2,
82
                    196 => 1,
83
                    199 => 3, // +1 for "excessive @throws" tag.
84
                    210 => 1,
85
                    211 => 1,
86
                    222 => 1,
87
                    223 => 1,
88
                    224 => 1,
89
                    225 => 1,
90
                    226 => 1,
91
                    227 => 1,
92
                    230 => 2,
93
                    232 => 2,
94
                    246 => 1,
95
                    248 => 4,
96
                    261 => 1,
97
                    263 => 1,
98
                    276 => 1,
99
                    277 => 1,
100
                    278 => 1,
101
                    279 => 1,
102
                    280 => 1,
103
                    281 => 1,
104
                    284 => 1,
105
                    286 => 7,
106
                    294 => 1,
107
                    302 => 1,
108
                    312 => 1,
109
                    358 => 1,
110
                    359 => 2,
111
                    372 => 1,
112
                    373 => 1,
113
                    387 => 1,
114
                    407 => 1,
115
                    441 => 1,
116
                    500 => 1,
117
                    526 => 1,
118
                    548 => 1,
119
                    641 => 1,
120
                    657 => 1,
121
                   );
122
123
            return $ret;
124
        } elseif ($testFile === 'FunctionCommentUnitTest.2.inc') {
125
            return array(
126
                    // Square bracket not allowed as function short description start.
127
                    7  => 1,
128
129
                    // Square bracket is allowed as event short description start.
130
                    17 => 0,
131
132
                    // Incorrect event short description start.
133
                    27 => 1,
134
                   );
135
        } elseif ($testFile === 'FunctionCommentUnitTest.3.inc') {
136
            $ret = array(
137
                    // Square bracket not allowed as function short description start.
138
                    7  => 1,
139
140
                    // Square bracket is allowed as event short description start.
141
                    17 => 0,
142
143
                    // Incorrect event short description start.
144
                    27 => 1,
145
                   );
146
147
            return $ret;
148
        }//end if
149
150
        return array();
151
    }//end getErrorList()
152
153
154
    /**
155
     * Returns the lines where warnings should occur.
156
     *
157
     * The key of the array should represent the line number and the value
158
     * should represent the number of warnings that should occur on that line.
159
     *
160
     * @param string $testFile Name of the file with test data.
161
     *
162
     * @return array(int => int)
163
     */
164
    public function getWarningList($testFile)
165
    {
166
        return array();
167
    }//end getWarningList()
168
}//end class
169