Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8a2c80c

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

15 files changed

+55
-29
lines changed

src/Angular.js

+4-2
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

+2-1
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

+4-2
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

+2-1
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

+6-3
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

+4-2
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

+8-4
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

+7-5
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

+2-1
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

+2-1
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

src/ngScenario/Runner.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ angular.scenario.Runner.prototype.emit = function(eventName) {
3636
var self = this;
3737
var args = Array.prototype.slice.call(arguments, 1);
3838
eventName = eventName.toLowerCase();
39-
if (!this.listeners[eventName])
39+
if (!this.listeners[eventName]) {
4040
return;
41+
}
4142
angular.forEach(this.listeners[eventName], function(listener) {
4243
listener.apply(self, args);
4344
});
@@ -157,8 +158,9 @@ angular.scenario.Runner.prototype.createSpecRunner_ = function(scope) {
157158

158159
// Export all the methods to child scope manually as now we don't mess controllers with scopes
159160
// TODO(vojta): refactor scenario runner so that these objects are not tightly coupled as current
160-
for (var name in Cls.prototype)
161+
for (var name in Cls.prototype) {
161162
child[name] = angular.bind(child, Cls.prototype[name]);
163+
}
162164

163165
Cls.call(child);
164166
return child;

src/ngScenario/Scenario.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
4242
/* jshint -W040 *//* The dsl binds `this` for us when calling chained functions */
4343
function executeStatement(statement, args) {
4444
var result = statement.apply(this, args);
45-
if (angular.isFunction(result) || result instanceof angular.scenario.Future)
45+
if (angular.isFunction(result) || result instanceof angular.scenario.Future) {
4646
return result;
47+
}
4748
var self = this;
4849
var chain = angular.extend({}, result);
4950
angular.forEach(chain, function(value, name) {

src/ngScenario/dsl.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ angular.scenario.dsl('repeater', function() {
276276
return this.addFutureAction("repeater '" + this.label + "' row '" + index + "'",
277277
function($window, $document, done) {
278278
var matches = $document.elements().slice(index, index + 1);
279-
if (!matches.length)
279+
if (!matches.length) {
280280
return done('row ' + index + ' out of bounds');
281+
}
281282
done(null, matches.bindings($window.angular.element));
282283
});
283284
};

test/helpers/testabilityPatch.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ function sortedHtml(element, showNgClass) {
160160
attrs.push(' class="' + className + '"');
161161
}
162162
for (var i = 0; i < attributes.length; i++) {
163-
if (i > 0 && attributes[i] == attributes[i - 1])
163+
if (i > 0 && attributes[i] == attributes[i - 1]) {
164164
continue; //IE9 creates dupes. Ignore them!
165+
}
165166

166167
var attr = attributes[i];
167168
if (attr.name.match(/^ng[\:\-]/) ||
@@ -221,8 +222,9 @@ function sortedHtml(element, showNgClass) {
221222
var tmp = style;
222223
style = [];
223224
forEach(tmp, function(value) {
224-
if (!value.match(/^max[^\-]/))
225+
if (!value.match(/^max[^\-]/)) {
225226
style.push(value);
227+
}
226228
});
227229
if (style.length) {
228230
html += ' style="' + style.join('; ') + ';"';

test/ngScenario/SpecRunnerSpec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ describe('angular.scenario.SpecRunner', function() {
4343
runner = $root.$new();
4444

4545
var Cls = angular.scenario.SpecRunner;
46-
for (var name in Cls.prototype)
46+
for (var name in Cls.prototype) {
4747
runner[name] = angular.bind(runner, Cls.prototype[name]);
48+
}
4849

4950
Cls.call(runner);
5051
}));

0 commit comments

Comments
 (0)