| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 10 | module.exports = function( grunt ) { |
||
| 11 | require( 'load-grunt-tasks' )( grunt ); |
||
| 12 | |||
| 13 | // Project configuration. |
||
| 14 | grunt.initConfig( { |
||
| 15 | // Package. |
||
| 16 | pkg: grunt.file.readJSON( 'package.json' ), |
||
| 17 | |||
| 18 | // JSHint. |
||
| 19 | jshint: { |
||
| 20 | all: [ 'Gruntfile.js', 'composer.json', 'package.json' ] |
||
| 21 | }, |
||
| 22 | |||
| 23 | // PHP Code Sniffer. |
||
| 24 | phpcs: { |
||
| 25 | application: { |
||
| 26 | src: [ |
||
| 27 | '**/*.php', |
||
| 28 | '!node_modules/**', |
||
| 29 | '!vendor/**', |
||
| 30 | '!wp-content/**' |
||
| 31 | ] |
||
| 32 | }, |
||
| 33 | options: { |
||
| 34 | bin: 'vendor/bin/phpcs', |
||
| 35 | standard: 'phpcs.xml.dist', |
||
| 36 | showSniffCodes: true |
||
| 37 | } |
||
| 38 | }, |
||
| 39 | |||
| 40 | // PHPLint. |
||
| 41 | phplint: { |
||
| 42 | all: [ 'src/**/*.php' ] |
||
| 43 | }, |
||
| 44 | |||
| 45 | // PHP Mess Detector. |
||
| 46 | phpmd: { |
||
| 47 | application: { |
||
| 48 | dir: 'src' |
||
| 49 | }, |
||
| 50 | options: { |
||
| 51 | bin: 'vendor/bin/phpmd', |
||
| 52 | exclude: 'node_modules', |
||
| 53 | reportFormat: 'xml', |
||
| 54 | rulesets: 'phpmd.xml.dist' |
||
| 55 | } |
||
| 56 | }, |
||
| 57 | |||
| 58 | // PHPUnit. |
||
| 59 | phpunit: { |
||
| 60 | options: { |
||
| 61 | bin: 'vendor/bin/phpunit' |
||
| 62 | }, |
||
| 63 | application: {} |
||
| 64 | } |
||
| 65 | } ); |
||
| 66 | |||
| 67 | // Default task(s). |
||
| 68 | grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpmd', 'phpcs' ] ); |
||
| 69 | }; |
||
| 70 |