Skip to content

Commit b05773b

Browse files
committed
Fixed linting issues
1 parent df9a1cf commit b05773b

4 files changed

Lines changed: 29 additions & 33 deletions

File tree

packages/common/src/metadata.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
'use strict';
2222

23-
var request = require('request');
2423
var util = require('./util.js');
2524

2625
var METADATA_URL = 'http://metadata.google.internal/computeMetadata/v1';
@@ -42,7 +41,7 @@ metadata.getMetadataValue = getMetadataValue;
4241
/**
4342
* Attempts to retreive the project id for the current active project from the
4443
* metadata service (See https://cloud.google.com/compute/docs/metadata).
45-
*
44+
*
4645
* @param {Object} [headers] - An optional set of headers to include in the http
4746
* request. This function may mutate the given headers object.
4847
* @param {function(?, number):?} callback an (err, result) style callback
@@ -53,15 +52,16 @@ function getProjectId(headers, callback) {
5352
headers = {};
5453
}
5554
getMetadataValue('/project/project-id', headers,
56-
function (err, projectId, response) {
55+
function(err, projectId, response) {
5756
if (!err && response.statusCode === 200) {
5857
return callback(null, projectId);
59-
} else if (err && err.code === 'ENOTFOUND') {
58+
}
59+
if (err && err.code === 'ENOTFOUND') {
6060
return callback(new Error('Could not auto-discover project-id.' +
6161
'Please export GCLOUD_PROJECT with your project name'), null);
6262
}
6363
return callback(err || new Error('Error discovering project id'), null);
64-
});
64+
});
6565
}
6666

6767
metadata.getProjectId = getProjectId;

packages/common/test/metadata.js

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
'use strict';
1717
var assert = require('assert');
1818
var nock = require('nock');
19-
var path = require('path');
2019
var proxyquire = require('proxyquire');
2120

2221
describe('common/metadata', function() {
@@ -62,7 +61,7 @@ describe('common/metadata', function() {
6261
done();
6362
});
6463
});
65-
64+
6665
it('should be able handle 500\'s from the service',
6766
function(done) {
6867
var scope = nock('http://metadata.google.internal')
@@ -83,26 +82,26 @@ describe('common/metadata', function() {
8382
it('should accept an optional headers parameter', function(done) {
8483
var scope =
8584
nock('http://metadata.google.internal', {
86-
reqheaders: {'Flux': 'Capacitor'}
85+
reqheaders: { Flux: 'Capacitor' }
8786
})
8887
.get('/computeMetadata/v1/project/project-id')
8988
.reply(200, 'a-stub-project-id');
90-
metadata.getProjectId({'Flux': 'Capacitor'}, function(err, project) {
89+
metadata.getProjectId({ Flux: 'Capacitor' }, function(err, project) {
9190
assert.ok(!err);
9291
assert.strictEqual(project, 'a-stub-project-id');
9392
scope.done();
9493
done();
9594
});
9695
});
9796

98-
it('Should callback with ENOTFOUND', function (done) {
97+
it('should callback with ENOTFOUND', function(done) {
9998
var oldEnv = process.env.GCLOUD_PROJECT;
10099
process.env.GCLOUD_PROJECT = './this-should-not-exist.json';
101100
var scope = nock('http://metadata.google.internal')
102101
.get('/computeMetadata/v1/project/project-id')
103102
.once()
104-
.replyWithError({'message': 'Not Found', code: 'ENOTFOUND'});
105-
metadata.getProjectId(function (e, result) {
103+
.replyWithError({ message: 'Not Found', code: 'ENOTFOUND' });
104+
metadata.getProjectId(function(e, result) {
106105
assert.ok(e instanceof Error, 'e should be an instance of Error');
107106
assert.deepEqual(result, null);
108107
process.env.GCLOUD_PROJECT = oldEnv;
@@ -114,30 +113,29 @@ describe('common/metadata', function() {
114113

115114
describe('getInstanceId - valid cases', function() {
116115
var STUB_ID = 'a-stub-instance-id';
117-
it(
118-
'Should be able to get the instance id without additional headers supplied',
119-
function (done) {
116+
it('should be able to get the instance id without additional headers ' +
117+
'supplied',
118+
function(done) {
120119
var mock = nock('http://metadata.google.internal/computeMetadata/v1')
121120
.get('/instance/id')
122121
.once()
123122
.reply(200, STUB_ID);
124-
metadata.getInstanceId(function (err, id) {
123+
metadata.getInstanceId(function(err, id) {
125124
assert.deepEqual(err, null, 'Error should be null');
126125
assert.deepEqual(STUB_ID, id, 'The id should be the stub id');
127126
mock.done();
128127
done();
129128
});
130129
}
131130
);
132-
it(
133-
'Should be able to get the instance id with additional headers supplied',
134-
function (done) {
131+
it('should be able to get the instance id with additional headers supplied',
132+
function(done) {
135133
var mock = nock('http://metadata.google.internal/computeMetadata/v1',
136134
{reqHeaders: {'x-custom-header': 'true'}})
137135
.get('/instance/id')
138136
.once()
139137
.reply(200, STUB_ID);
140-
metadata.getInstanceId({'x-custom-header': 'true'}, function (err, id) {
138+
metadata.getInstanceId({'x-custom-header': 'true'}, function(err, id) {
141139
assert.deepEqual(err, null, 'Error should be null');
142140
assert.deepEqual(STUB_ID, id, 'The id should be the stub id');
143141
mock.done();
@@ -149,14 +147,13 @@ describe('common/metadata', function() {
149147

150148
describe('getHostname - valid cases', function() {
151149
var STUB_HOSTNAME = 'a-stub-hostname';
152-
it(
153-
'Should be able to get the hostname without additional headers supplied',
154-
function (done) {
150+
it('should be able to get the hostname without additional headers supplied',
151+
function(done) {
155152
var mock = nock('http://metadata.google.internal/computeMetadata/v1')
156153
.get('/instance/hostname')
157154
.once()
158155
.reply(200, STUB_HOSTNAME);
159-
metadata.getHostname(function (err, id) {
156+
metadata.getHostname(function(err, id) {
160157
assert.deepEqual(err, null, 'Error should be null');
161158
assert.deepEqual(STUB_HOSTNAME, id,
162159
'The hostname should be the stub hostname');
@@ -165,15 +162,14 @@ describe('common/metadata', function() {
165162
});
166163
}
167164
);
168-
it(
169-
'Should be able to get the hostname with additional headers supplied',
170-
function (done) {
165+
it('should be able to get the hostname with additional headers supplied',
166+
function(done) {
171167
var mock = nock('http://metadata.google.internal/computeMetadata/v1',
172168
{reqHeaders: {'x-custom-header': 'true'}})
173169
.get('/instance/hostname')
174170
.once()
175171
.reply(200, STUB_HOSTNAME);
176-
metadata.getHostname({'x-custom-header': 'true'}, function (err, id) {
172+
metadata.getHostname({'x-custom-header': 'true'}, function(err, id) {
177173
assert.deepEqual(err, null, 'Error should be null');
178174
assert.deepEqual(STUB_HOSTNAME, id,
179175
'The hostname should be the stub hostname');

packages/common/test/paginator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ function override(name, object) {
4949
return cachedObject[methodName].apply(this, args);
5050
};
5151

52-
object[methodName].unoverride_ = function () {
52+
object[methodName].unoverride_ = function() {
5353
object[methodName] = cachedObject[methodName];
5454
};
5555
});
5656
}
5757

5858
// Reverses the override function.
5959
function unoverride(object) {
60-
Object.keys(object).forEach(function (methodName) {
60+
Object.keys(object).forEach(function(methodName) {
6161
if (object[methodName].unoverride_) {
6262
object[methodName].unoverride_();
6363
}
6464
});
6565
}
6666

67-
// Resets all overridden functions.
67+
// Resets all overridden functions.
6868
function resetOverrides() {
6969
overrides = Object.keys(overrides).reduce(function(acc, name) {
7070
acc[name] = {};

packages/common/test/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ describe('common/util', function() {
9898

9999
after(function() {
100100
// Set each function in util to its original value
101-
Object.keys(util).forEach(function (utilMethod) {
101+
Object.keys(util).forEach(function(utilMethod) {
102102
if (util[utilMethod].unoverride_) {
103103
util[utilMethod].unoverride_();
104104
}
105-
})
105+
});
106106
});
107107

108108
it('should have set correct defaults on Request', function() {

0 commit comments

Comments
 (0)