Skip to content

Commit 9062a5f

Browse files
committed
JS: Update OK-style comments to $-style
1 parent 3b936d6 commit 9062a5f

File tree

531 files changed

+4297
-4570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

531 files changed

+4297
-4570
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
angular.module('myModule', [])
22
.controller('MyController', function($scope) {
3-
$scope.$on('destroy', cleanup); // BAD
3+
$scope.$on('destroy', cleanup); // $ Alert
44
})
55
.controller('MyController', ["$scope", function(s) {
6-
s.$on('destroy', cleanup); // BAD
6+
s.$on('destroy', cleanup); // $ Alert
77
}])
88
.controller('MyController', function($scope) {
99
var destroy = 'destroy';
10-
$scope.$on(destroy, cleanup); // BAD
10+
$scope.$on(destroy, cleanup); // $ Alert
1111
})
1212
.controller('MyController', function($scope) {
13-
$scope.$on('$destroy', cleanup); // GOOD
13+
$scope.$on('$destroy', cleanup);
1414
})
1515
.controller('MyController', function($scope) {
1616
$scope.$emit('foo');
17-
$scope.$on('foo', cleanup); // GOOD
17+
$scope.$on('foo', cleanup);
1818
})
1919
.controller('MyController', function($scope) {
20-
$scope.$on('bar', cleanup); // BAD
20+
$scope.$on('bar', cleanup); // $ Alert
2121
})
2222
.controller('MyController', function($scope) {
23-
$scope.$on('$locationChangeStart', cleanup); // OK
23+
$scope.$on('$locationChangeStart', cleanup);
2424
})
2525
.controller('MyController', function($scope) {
26-
$scope.$on('lib1.foo', cleanup); // OK
26+
$scope.$on('lib1.foo', cleanup);
2727
})
2828
.controller('MyController', function($scope) {
29-
$scope.$on('lib2:foo', cleanup); // OK
29+
$scope.$on('lib2:foo', cleanup);
3030
})
3131
.controller('MyController', function($scope) {
32-
$scope.$on('onClick', cleanup); // OK
32+
$scope.$on('onClick', cleanup);
3333
})
3434
.controller('MyController', function($scope) {
3535
function f($scope){
3636
$scope.$emit('probablyFromUserCode1')
3737
}
38-
$scope.$on('probablyFromUserCode1', cleanup); // OK
38+
$scope.$on('probablyFromUserCode1', cleanup);
3939
})
4040
.controller('MyController', function($scope) {
4141
function f($scope){
4242
var scope = $scope;
4343
scope.$emit('probablyFromUserCode2')
4444
}
45-
$scope.$on('probablyFromUserCode2', cleanup); // OK
45+
$scope.$on('probablyFromUserCode2', cleanup);
4646
})
4747
.controller('MyController', function($scope) {
48-
$scope.$on('event-from-AngularJS-expression', cleanup); // GOOD
48+
$scope.$on('event-from-AngularJS-expression', cleanup);
4949
})
5050
;
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
angular.module('app1', [])
2-
.run(['dep1', 'dep2', 'dep3', function(dep1, dep3, dep2) {}]); // NOT OK
2+
.run(['dep1', 'dep2', 'dep3', function(dep1, dep3, dep2) {}]); // $ Alert
33

44
angular.module('app2')
5-
.directive('mydirective', [ '$compile', function($compile, $http) { // NOT OK
5+
.directive('mydirective', [ '$compile', function($compile, $http) { // $ Alert
66
// ...
77
}]);
88

99
angular.module('app1', [])
10-
.run(['dep1', 'dep2', 'dep3', function(dep1, dep2, dep3) {}]); // OK
10+
.run(['dep1', 'dep2', 'dep3', function(dep1, dep2, dep3) {}]);
1111

1212
angular.module('app2')
13-
.directive('mydirective', [ '$compile', '$http', function($compile, $http) { // OK
13+
.directive('mydirective', [ '$compile', '$http', function($compile, $http) {
1414
// ...
1515
}]);
1616

1717
angular.module('app3', [])
18-
.run(function(dep1, dep3) {}); // OK
18+
.run(function(dep1, dep3) {});
1919

2020
angular.module('app4')
21-
.directive('mydirective', function($compile, $http) { // OK
21+
.directive('mydirective', function($compile, $http) {
2222
// ...
2323
});
2424

2525
angular.module('app5')
26-
.directive('mydirective', [ 'fully.qualified.name', function(name) { // OK
26+
.directive('mydirective', [ 'fully.qualified.name', function(name) {
2727
// ...
2828
}])
2929

3030
angular.module('app6')
3131
.directive('mydirective', function() {
3232
return {
33-
link: function (scope, element, attrs) { // OK
33+
link: function (scope, element, attrs) {
3434
}
3535
};
3636
});
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
angular.module('app', [])
22
.config(function($sceProvider) {
3-
$sceProvider.enabled(false); // BAD
3+
$sceProvider.enabled(false); // $ Alert
44
})
55
.config(['otherProvider', function($sceProvider) {
6-
$sceProvider.enabled(false); // OK
6+
$sceProvider.enabled(false);
77
}])
88
.config(['$sceProvider', function(x) {
9-
x.enabled(false); // BAD
9+
x.enabled(false); // $ Alert
1010
}])
1111
.config(function($sceProvider) {
12-
$sceProvider.enabled(true); // OK
12+
$sceProvider.enabled(true);
1313
})
1414
.config(function($sceProvider) {
1515
var x = false;
16-
$sceProvider.enabled(x); // BAD
16+
$sceProvider.enabled(x); // $ Alert
1717
});
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
(function(){
22
function f(){}
3-
f.$inject = ['dup5', 'dup5']; // NOT OK
3+
f.$inject = ['dup5', 'dup5']; // $ Alert
44
angular.module('myModule', [])
5-
.run(['dup1a', 'dup1a', function(dup1a, dup1a){}]) // OK (flagged by js/duplicate-parameter-name)
6-
.run(['dup2a', 'dup2a', function(dup2a, dup2b){}]) // NOT OK
7-
.run(['dup3b', 'dup3b', function(dup3a, dup3b){}]) // NOT OK
8-
.run(['dup4', 'notDup4A', 'dup4', function(notDup4B, dup4, notDup4C){}]) // NOT OK
5+
.run(['dup1a', 'dup1a', function(dup1a, dup1a){}]) // OK - flagged by js/duplicate-parameter-name
6+
.run(['dup2a', 'dup2a', function(dup2a, dup2b){}]) // $ Alert
7+
.run(['dup3b', 'dup3b', function(dup3a, dup3b){}]) // $ Alert
8+
.run(['dup4', 'notDup4A', 'dup4', function(notDup4B, dup4, notDup4C){}]) // $ Alert
99
.run(f)
10-
.run(function(dup6, dup6){})// OK (flagged by js/duplicate-parameter-name)
11-
.run(function(notDup7a, notDup7b){}) // OK
12-
.run(['notDup8a', 'notDup8b', function(notDup8a, notDup8b){}]) // OK
13-
.run(['notDup9a', 'notDup9b', function(notDup9c, notDup9d){}]) // OK
14-
.run(['dup10a', 'dup10a', 'dup10a', function(dup10a, dup10a, dup10a){}]) // OK (flagged by js/duplicate-parameter-name)
15-
.run(['dup11a', 'dup11a', function(dup11a, dup11b){ // NOT OK (alert formatting for multi-line function)
10+
.run(function(dup6, dup6){})// OK - flagged by js/duplicate-parameter-name
11+
.run(function(notDup7a, notDup7b){})
12+
.run(['notDup8a', 'notDup8b', function(notDup8a, notDup8b){}])
13+
.run(['notDup9a', 'notDup9b', function(notDup9c, notDup9d){}])
14+
.run(['dup10a', 'dup10a', 'dup10a', function(dup10a, dup10a, dup10a){}]) // OK - flagged by js/duplicate-parameter-name
15+
.run(['dup11a', 'dup11a', function(dup11a, dup11b){ // $ Alert - alert formatting for multi-line function
1616
}])
1717
;
1818
})();

javascript/ql/test/query-tests/AngularJS/IncompatibleService/angular-incompatible-service.js

+58-58
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,68 @@ angular.module('myModule', [])
1111
;
1212

1313
angular.module('myModule2', [])
14-
.controller('c0', function(factoryId){}) // OK
15-
.controller('c1', function(serviceId){}) // OK
16-
.controller('c2', function(valueId){}) // OK
17-
.controller('c3', function(constantId){}) // OK
18-
.controller('c4', function(providerId){}) // OK
19-
.controller('c5', function($http){}) // OK
20-
.controller('c6', function($provider){}) // NOT OK
21-
.controller('c7', function($scope){}) // OK
22-
.controller('c8', function($compile){}) // OK
23-
.controller('c9', function(UNKNOWN){}) // OK
24-
.controller('c10', function(providerIdProvider){}) // NOT OK
25-
.controller('c11', function(providerIdProvider, UNKNOWN){}) // NOT OK, but only one error
26-
.controller('c12', function($provide){}) // OK (special case)
27-
.controller('c13', function(providerId2Provider){}) // NOT OK
14+
.controller('c0', function(factoryId){})
15+
.controller('c1', function(serviceId){})
16+
.controller('c2', function(valueId){})
17+
.controller('c3', function(constantId){})
18+
.controller('c4', function(providerId){})
19+
.controller('c5', function($http){})
20+
.controller('c6', function($provider){}) // $ Alert
21+
.controller('c7', function($scope){})
22+
.controller('c8', function($compile){})
23+
.controller('c9', function(UNKNOWN){})
24+
.controller('c10', function(providerIdProvider){}) // $ Alert
25+
.controller('c11', function(providerIdProvider, UNKNOWN){}) // $ Alert - but only one error
26+
.controller('c12', function($provide){}) // OK - special case
27+
.controller('c13', function(providerId2Provider){}) // $ Alert
2828

29-
.factory('s0', function(factoryId){}) // OK
30-
.factory('s1', function(serviceId){}) // OK
31-
.factory('s2', function(valueId){}) // OK
32-
.factory('s3', function(constantId){}) // OK
33-
.factory('s4', function(providerId){}) // OK
34-
.factory('s5', function($http){}) // OK
35-
.factory('s6', function($provider){}) // NOT OK
36-
.factory('s7', function($scope){}) // NOT OK
37-
.factory('s8', function($compile){}) // OK
38-
.factory('s9', function(UNKNOWN){}) // OK
39-
.factory('s10', function(providerIdProvider){}) // NOT OK
40-
.factory('s11', function(providerIdProvider, UNKNOWN){}) // NOT OK, but only one error
41-
.factory('s12', function($provide){}) // OK (special case)
42-
.factory('s13', function(providerId2Provider){}) // NOT OK
29+
.factory('s0', function(factoryId){})
30+
.factory('s1', function(serviceId){})
31+
.factory('s2', function(valueId){})
32+
.factory('s3', function(constantId){})
33+
.factory('s4', function(providerId){})
34+
.factory('s5', function($http){})
35+
.factory('s6', function($provider){}) // $ Alert
36+
.factory('s7', function($scope){}) // $ Alert
37+
.factory('s8', function($compile){})
38+
.factory('s9', function(UNKNOWN){})
39+
.factory('s10', function(providerIdProvider){}) // $ Alert
40+
.factory('s11', function(providerIdProvider, UNKNOWN){}) // $ Alert - but only one error
41+
.factory('s12', function($provide){}) // OK - special case
42+
.factory('s13', function(providerId2Provider){}) // $ Alert
4343

44-
.run(function(factoryId){}) // OK
45-
.run(function(serviceId){}) // OK
46-
.run(function(valueId){}) // OK
47-
.run(function(constantId){}) // OK
48-
.run(function(providerId){}) // OK
49-
.run(function($http){}) // OK
50-
.run(function($provider){}) // NOT OK
51-
.run(function($scope){}) // NOT OK
52-
.run(function($compile){}) // OK
53-
.run(function(UNKNOWN){}) // OK
54-
.run(function(providerIdProvider){}) // NOT OK
55-
.run(function(providerIdProvider, UNKNOWN){}) // NOT OK, but only one error
56-
.run(function($provide){}) // OK (special case)
57-
.run(function(providerId2Provider){}) // NOT OK
44+
.run(function(factoryId){})
45+
.run(function(serviceId){})
46+
.run(function(valueId){})
47+
.run(function(constantId){})
48+
.run(function(providerId){})
49+
.run(function($http){})
50+
.run(function($provider){}) // $ Alert
51+
.run(function($scope){}) // $ Alert
52+
.run(function($compile){})
53+
.run(function(UNKNOWN){})
54+
.run(function(providerIdProvider){}) // $ Alert
55+
.run(function(providerIdProvider, UNKNOWN){}) // $ Alert - but only one error
56+
.run(function($provide){}) // OK - special case
57+
.run(function(providerId2Provider){}) // $ Alert
5858

59-
.config(function(factoryId){}) // NOT OK
60-
.config(function(serviceId){}) // NOT OK
61-
.config(function(valueId){}) // NOT OK
62-
.config(function(constantId){}) // OK
63-
.config(function(providerId){}) // NOT OK
64-
.config(function($http){}) // NOT OK
65-
.config(function($provider){}) // OK
66-
.config(function($scope){}) // NOT OK
67-
.config(function($compile){}) // OK
68-
.config(function(UNKNOWN){}) // OK
69-
.config(function(providerIdProvider){}) // OK
70-
.config(function(providerId, UNKNOWN){}) // NOT OK, but only one error
71-
.config(function($provide){}) // OK (special case)
72-
.config(function(valueId2){}) // NOT OK
59+
.config(function(factoryId){}) // $ Alert
60+
.config(function(serviceId){}) // $ Alert
61+
.config(function(valueId){}) // $ Alert
62+
.config(function(constantId){})
63+
.config(function(providerId){}) // $ Alert
64+
.config(function($http){}) // $ Alert
65+
.config(function($provider){})
66+
.config(function($scope){}) // $ Alert
67+
.config(function($compile){})
68+
.config(function(UNKNOWN){})
69+
.config(function(providerIdProvider){})
70+
.config(function(providerId, UNKNOWN){}) // $ Alert - but only one error
71+
.config(function($provide){}) // OK - special case
72+
.config(function(valueId2){}) // $ Alert
7373

7474
// service: same restrcitions as .factory
75-
.service('s14', function(factoryId){}) // OK
76-
.service('s15', function($provider){}) // NOT OK
75+
.service('s14', function(factoryId){})
76+
.service('s15', function($provider){}) // $ Alert
7777

7878
;
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
angular.module('myApp', [])
22
.config(function($sceDelegateProvider) {
33
$sceDelegateProvider.resourceUrlWhitelist([
4-
"**://example.com/*", // BAD (exploit: http://evil.com/?ignore=://example.org/a or javascript:alert(1);://example.org/a)
5-
"*://example.org/*", // BAD (exploit: javascript://example.org/a%0A%0Dalert(1) using a linebreak to end the comment starting with "//"!)
6-
"https://**.example.com/*", // BAD (exploit: https://evil.com/?ignore=://example.com/a)
7-
"https://example.**", // BAD (exploit: https://example.evil.com or http://example.:[email protected])
8-
"https://example.*", // BAD (exploit: https://example.UnexpectedTLD)
4+
"**://example.com/*", // $ Alert - (exploit: http://evil.com/?ignore=://example.org/a or javascript:alert(1);://example.org/a)
5+
"*://example.org/*", // $ Alert - (exploit: javascript://example.org/a%0A%0Dalert(1) using a linebreak to end the comment starting with "//"!)
6+
"https://**.example.com/*", // $ Alert - exploit: https://evil.com/?ignore=://example.com/a
7+
"https://example.**", // $ Alert - exploit: https://example.evil.com or http://example.:[email protected]
8+
"https://example.*", // $ Alert - exploit: https://example.UnexpectedTLD
99

10-
"https://example.com", // OK
11-
"https://example.com/**", // OK
12-
"https://example.com/*", // OK
13-
"https://example.com/foo/*", // OK
14-
"https://example.com/foo/**", // OK
15-
"https://example.com/foo/*/bar", // OK
16-
"https://example.com/foo/**/bar", // OK
17-
"https://example.com/?**", // OK
18-
"https://example.com/?**://example.com", // OK
10+
"https://example.com",
11+
"https://example.com/**",
12+
"https://example.com/*",
13+
"https://example.com/foo/*",
14+
"https://example.com/foo/**",
15+
"https://example.com/foo/*/bar",
16+
"https://example.com/foo/**/bar",
17+
"https://example.com/?**",
18+
"https://example.com/?**://example.com",
1919
"https://*.example.com",
2020

2121
// not flagged:
22-
/http:\/\/www.example.org/g // BAD (exploit http://wwwaexample.org (dots are not escaped))
22+
/http:\/\/www.example.org/g // $ Alert - (exploit http://wwwaexample.org (dots are not escaped))
2323
]);
2424
});
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
(function(){
2-
function injected1(name){} // NOT OK
2+
function injected1(name){} // $ Alert
33
angular.module('app1').controller('controller1', injected1);
44

5-
function injected2(name){} // OK
5+
function injected2(name){}
66
injected2.$inject = ['name'];
77
angular.module('app2').controller('controller2', injected2);
88

9-
function injected3(name){} // OK
9+
function injected3(name){}
1010
angular.module('app3').controller('controller3', ['name', injected3]);
1111

12-
angular.module('app4').controller('controller4', function(){}); // OK
12+
angular.module('app4').controller('controller4', function(){});
1313

14-
angular.module('app5').controller('controller5', function(name){}); // NOT OK
14+
angular.module('app5').controller('controller5', function(name){}); // $ Alert
1515

16-
function injected6(){} // OK
16+
function injected6(){}
1717
angular.module('app6').controller('controller6', injected6);
1818

19-
function notInjected7(name){} // OK
19+
function notInjected7(name){}
2020
var obj7 = {
2121
controller: notInjected7
2222
};
2323

24-
function injected8(name){} // OK (false negative: we do not track through properties)
24+
function injected8(name){} // OK - false negative: we do not track through properties
2525
var obj8 = {
2626
controller: injected8
2727
};
2828
angular.module('app8').controller('controller8', obj8.controller);
2929

3030
var $injector = angular.injector();
3131

32-
function injected9(name){} // NOT OK
32+
function injected9(name){} // $ Alert
3333
$injector.invoke(injected9)
3434

35-
function injected10(name){} // OK
35+
function injected10(name){}
3636
injected10.$inject = ['name'];
3737
$injector.invoke(injected10)
3838

39-
function injected11(name){} // OK
39+
function injected11(name){}
4040
$injector.invoke(['name', injected11])
4141

4242
})();

0 commit comments

Comments
 (0)