Skip to content

Commit 8a2c80c

Browse files
rzschechpetebacondarwin
authored andcommitted
style(*) add curly braces to multiline if and for statements
Closes angular#10865
1 parent 2f3633d commit 8a2c80c

15 files changed

Lines changed: 55 additions & 29 deletions

File tree

src/Angular.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,9 @@ function isElement(node) {
626626
*/
627627
function makeMap(str) {
628628
var obj = {}, items = str.split(","), i;
629-
for (i = 0; i < items.length; i++)
629+
for (i = 0; i < items.length; i++) {
630630
obj[items[i]] = true;
631+
}
631632
return obj;
632633
}
633634

@@ -642,8 +643,9 @@ function includes(array, obj) {
642643

643644
function arrayRemove(array, value) {
644645
var index = array.indexOf(value);
645-
if (index >= 0)
646+
if (index >= 0) {
646647
array.splice(index, 1);
648+
}
647649
return index;
648650
}
649651

src/jqLite.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,9 @@ forEach({
851851
children: function(element) {
852852
var children = [];
853853
forEach(element.childNodes, function(element) {
854-
if (element.nodeType === NODE_TYPE_ELEMENT)
854+
if (element.nodeType === NODE_TYPE_ELEMENT) {
855855
children.push(element);
856+
}
856857
});
857858
return children;
858859
},

src/ng/filter/filters.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ function padNumber(num, digits, trim) {
234234
}
235235
num = '' + num;
236236
while (num.length < digits) num = '0' + num;
237-
if (trim)
237+
if (trim) {
238238
num = num.substr(num.length - digits);
239+
}
239240
return neg + num;
240241
}
241242

@@ -244,8 +245,9 @@ function dateGetter(name, size, offset, trim) {
244245
offset = offset || 0;
245246
return function(date) {
246247
var value = date['get' + name]();
247-
if (offset > 0 || value > -offset)
248+
if (offset > 0 || value > -offset) {
248249
value += offset;
250+
}
249251
if (value === 0 && offset == -12) value = 12;
250252
return padNumber(value, size, trim);
251253
};

src/ng/http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ function headersGetter(headers) {
9898
* @returns {*} Transformed data.
9999
*/
100100
function transformData(data, headers, status, fns) {
101-
if (isFunction(fns))
101+
if (isFunction(fns)) {
102102
return fns(data, headers, status);
103+
}
103104

104105
forEach(fns, function(fn) {
105106
data = fn(data, headers, status);

src/ng/location.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ var locationPrototype = {
373373
* @return {string} url
374374
*/
375375
url: function(url) {
376-
if (isUndefined(url))
376+
if (isUndefined(url)) {
377377
return this.$$url;
378+
}
378379

379380
var match = PATH_MATCH.exec(url);
380381
if (match[1] || url === '') this.path(decodeURIComponent(match[1]));
@@ -613,8 +614,9 @@ forEach([LocationHashbangInHtml5Url, LocationHashbangUrl, LocationHtml5Url], fun
613614
* @return {object} state
614615
*/
615616
Location.prototype.state = function(state) {
616-
if (!arguments.length)
617+
if (!arguments.length) {
617618
return this.$$state;
619+
}
618620

619621
if (Location !== LocationHtml5Url || !this.$$html5) {
620622
throw $locationMinErr('nostate', 'History API state support is available only ' +
@@ -639,8 +641,9 @@ function locationGetter(property) {
639641

640642
function locationGetterSetter(property, preprocess) {
641643
return function(value) {
642-
if (isUndefined(value))
644+
if (isUndefined(value)) {
643645
return this[property];
646+
}
644647

645648
this[property] = preprocess(value);
646649
this.$$compose();

src/ng/parse.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ Lexer.prototype = {
235235
if (escape) {
236236
if (ch === 'u') {
237237
var hex = this.text.substring(this.index + 1, this.index + 5);
238-
if (!hex.match(/[\da-f]{4}/i))
238+
if (!hex.match(/[\da-f]{4}/i)) {
239239
this.throwError('Invalid unicode escape [\\u' + hex + ']');
240+
}
240241
this.index += 4;
241242
string += String.fromCharCode(parseInt(hex, 16));
242243
} else {
@@ -544,8 +545,9 @@ AST.prototype = {
544545
},
545546

546547
peekToken: function() {
547-
if (this.tokens.length === 0)
548+
if (this.tokens.length === 0) {
548549
throw $parseMinErr('ueoe', 'Unexpected end of expression: {0}', this.text);
550+
}
549551
return this.tokens[0];
550552
},
551553

src/ngMock/angular-mocks.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,9 @@ function padNumber(num, digits, trim) {
599599
}
600600
num = '' + num;
601601
while (num.length < digits) num = '0' + num;
602-
if (trim)
602+
if (trim) {
603603
num = num.substr(num.length - digits);
604+
}
604605
return neg + num;
605606
}
606607

@@ -650,11 +651,12 @@ angular.mock.TzDate = function(offset, timestamp) {
650651
self.origDate = jsonStringToDate(timestamp);
651652

652653
timestamp = self.origDate.getTime();
653-
if (isNaN(timestamp))
654+
if (isNaN(timestamp)) {
654655
throw {
655656
name: "Illegal Argument",
656657
message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string"
657658
};
659+
}
658660
} else {
659661
self.origDate = new Date(timestamp);
660662
}
@@ -1184,14 +1186,16 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
11841186
}
11851187

11861188
if (expectation && expectation.match(method, url)) {
1187-
if (!expectation.matchData(data))
1189+
if (!expectation.matchData(data)) {
11881190
throw new Error('Expected ' + expectation + ' with different data\n' +
11891191
'EXPECTED: ' + prettyPrint(expectation.data) + '\nGOT: ' + data);
1192+
}
11901193

1191-
if (!expectation.matchHeaders(headers))
1194+
if (!expectation.matchHeaders(headers)) {
11921195
throw new Error('Expected ' + expectation + ' with different headers\n' +
11931196
'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' +
11941197
prettyPrint(headers));
1198+
}
11951199

11961200
expectations.shift();
11971201

src/ngSanitize/sanitize.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,9 @@ function htmlParser(html, handler) {
372372

373373
unary = voidElements[tagName] || !!unary;
374374

375-
if (!unary)
375+
if (!unary) {
376376
stack.push(tagName);
377+
}
377378

378379
var attrs = {};
379380

@@ -392,11 +393,12 @@ function htmlParser(html, handler) {
392393
function parseEndTag(tag, tagName) {
393394
var pos = 0, i;
394395
tagName = angular.lowercase(tagName);
395-
if (tagName)
396+
if (tagName) {
396397
// Find the closest opened tag of the same type
397-
for (pos = stack.length - 1; pos >= 0; pos--)
398-
if (stack[pos] == tagName)
399-
break;
398+
for (pos = stack.length - 1; pos >= 0; pos--) {
399+
if (stack[pos] == tagName) break;
400+
}
401+
}
400402

401403
if (pos >= 0) {
402404
// Close all the open elements, up the stack

src/ngScenario/Application.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ angular.scenario.Application.prototype.getFrame_ = function() {
3434
*/
3535
angular.scenario.Application.prototype.getWindow_ = function() {
3636
var contentWindow = this.getFrame_().prop('contentWindow');
37-
if (!contentWindow)
37+
if (!contentWindow) {
3838
throw 'Frame window is not accessible.';
39+
}
3940
return contentWindow;
4041
};
4142

src/ngScenario/ObjectModel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ angular.scenario.ObjectModel = function(runner) {
7676
runner.on('StepEnd', function(spec) {
7777
var it = self.getSpec(spec.id);
7878
var step = it.getLastStep();
79-
if (step.name !== step.name)
79+
if (step.name !== step.name) {
8080
throw 'Events fired in the wrong order. Step names don\'t match.';
81+
}
8182
complete(step);
8283

8384
// forward the event

0 commit comments

Comments
 (0)