Completed
Push — next ( 8ef386...43bb99 )
by Thomas
11:01 queued 05:16
created

module.exports   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 169

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 169
rs 8.2857
c 1
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
module.exports = function (grunt) {
2
    require('load-grunt-tasks')(grunt);
3
    require('time-grunt')(grunt);
4
5
    grunt.initConfig({
6
        dirs: {
7
            source: 'app/Resources/assets',
8
            destination: 'web/assets'
9
        },
10
11
        clean: {
12
            all: '<%= dirs.destination %>',
13
            css: '<%= dirs.destination %>/css/',
14
            js: '<%= dirs.destination %>/js/',
15
            images: '<%= dirs.destination %>/images/'
16
        },
17
        scsslint: {
18
            development: [
19
                '<%= dirs.source %>/scss/**/*'
20
            ],
21
            options: {
22
                config: '.scss-lint.yml',
23
                reporterOutput: 'scss-lint-report.xml',
24
                colorizeOutput: true
25
            }
26
        },
27
        copyto: {
28
            images: {
29
                files: [
30
                    {cwd: '<%= dirs.source %>/images/', src: ['**/*'], dest: '<%= dirs.destination %>/images/', expand: true}
31
                ],
32
            }
33
        },
34
        sass: {
35
            production: {
36
                options: {
37
                    style: 'compressed'
38
                },
39
                files: {
40
                    '<%= dirs.destination %>/css/style.min.css': '<%= dirs.source %>/scss/all.scss',
41
                    '<%= dirs.destination %>/css/legacy.min.css': '<%= dirs.source %>/scss/legacy.scss'
42
                }
43
            },
44
            development: {
45
                options: {
46
                    sourceMap: true,
47
                    style: 'expanded'
48
                },
49
                files: {
50
                    '<%= dirs.destination %>/css/style.min.css': '<%= dirs.source %>/scss/all.scss',
51
                    '<%= dirs.destination %>/css/legacy.min.css': '<%= dirs.source %>/scss/legacy.scss'
52
                }
53
            },
54
            options: {
55
                importer: require('grunt-sass-tilde-importer'),
56
                includePaths: [
57
                    '<%= dirs.source %>/scss/'
58
                ]
59
            }
60
        },
61
        cssmin: {
62
            options: {
63
                shorthandCompacting: false,
64
                roundingPrecision: -1
65
            },
66
            target: {
67
                files: {
68
                    '<%= dirs.destination %>/css/style.min.css': [
69
                        '<%= dirs.destination %>/css/style.min.css'
70
                    ],
71
                    '<%= dirs.destination %>/css/legacy.min.css': [
72
                        '<%= dirs.destination %>/css/legacy.min.css'
73
                    ]
74
                }
75
            }
76
        },
77
        uglify: {
78
            production: {
79
                options: {
80
                    mangleProperties: false,
81
                    reserveDOMProperties: true
82
                },
83
                files: {
84
                    '<%= dirs.destination %>/js/main.js': [
85
                        '<%= dirs.source %>/js/**/*.js'
86
                    ]
87
                }
88
            },
89
            development: {
90
                options: {
91
                    sourceMap: true,
92
                    beautify: true,
93
                    mangle: false,
94
                    compress: false
95
                },
96
            },
97
        },
98
        watch: {
99
            images: {
100
                files: [
101
                    '<%= dirs.source %>/images/**/*'
102
                ],
103
                tasks: [
104
                    'copyto:images'
105
                ]
106
            },
107
            css: {
108
                files: [
109
                    '<%= dirs.source %>/scss/**/*.scss'
110
                ],
111
                tasks: [
112
                    'development:css'
113
                ],
114
                options: {
115
                    spawn: false
116
                }
117
            },
118
            scripts: {
119
                files: [
120
                    '<%= dirs.source %>/js/**/*.js'
121
                ],
122
                tasks: [
123
                    'development:js'
124
                ]
125
            },
126
            options: {
127
                atBegin: true
128
            }
129
        }
130
    });
131
132
133
    grunt.registerTask('default', [
134
        'build'
135
    ]);
136
137
    //Builds css&js once for development
138
    grunt.registerTask('build', [
139
        'clean:all',
140
        'uglify',
141
        'sass:development'
142
    ]);
143
144
    grunt.registerTask('development:css', [
145
        'scsslint:development',
146
        'clean:css',
147
        'sass:development'
148
    ]);
149
150
    grunt.registerTask('development:js', [
151
        'clean:js',
152
        'uglify:development'
153
    ]);
154
155
    grunt.registerTask('development', [
156
        'development:js',
157
        'development:css'
158
    ]);
159
160
    //Builds css&js once for production
161
    grunt.registerTask('production', [
162
        'clean:all',
163
        'uglify:production',
164
        'sass:production',
165
        'cssmin'
166
    ]);
167
168
    grunt.task.renameTask('chokidar', 'watch');
169
};
170