Skip to content

Commit e2d4316

Browse files
skarimoci.datadog-api-spec
andauthored
Apply static analysis changes (#1488)
* apply rules * generate * pre-commit fixes --------- Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 5ff8167 commit e2d4316

File tree

84 files changed

+2347
-2345
lines changed

Some content is hidden

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

84 files changed

+2347
-2345
lines changed

.generator/src/generator/templates/api/api.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class {{ className }}ResponseProcessor {
166166
{%- set responseSchema = response|parameter_schema %}
167167
if (
168168
{%- for responseCode in responseCodes -%}
169-
{%- if not loop.first -%} || {%- endif -%} response.httpStatusCode == {{ responseCode }}
169+
{%- if not loop.first -%} || {%- endif -%} response.httpStatusCode === {{ responseCode }}
170170
{%- endfor -%}
171171
) {
172172
{%- if responseType %}

.generator/src/generator/templates/http/isomorphic-fetch.j2

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { fetch as crossFetch } from "cross-fetch";
33
import pako from "pako";
44
import bufferFrom from "buffer-from";
55
import { isBrowser, isNode } from "../util";
6+
import { logger } from "../../../logger";
67

78
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
89
public debug = false;
@@ -27,11 +28,11 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
2728
const headers = request.getHeaders();
2829

2930
if (typeof body === "string") {
30-
if (headers["Content-Encoding"] == "gzip") {
31+
if (headers["Content-Encoding"] === "gzip") {
3132
body = bufferFrom(pako.gzip(body).buffer);
32-
} else if (headers["Content-Encoding"] == "deflate") {
33+
} else if (headers["Content-Encoding"] === "deflate") {
3334
body = bufferFrom(pako.deflate(body).buffer);
34-
} else if (headers["Content-Encoding"] == "zstd1") {
35+
} else if (headers["Content-Encoding"] === "zstd1") {
3536
if (this.zstdCompressorCallback) {
3637
body = this.zstdCompressorCallback(body);
3738
} else {
@@ -116,7 +117,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
116117
}
117118
return response;
118119
} catch (error) {
119-
console.error("An error occurred during the HTTP request:", error);
120+
logger.error("An error occurred during the HTTP request:", error);
120121
throw error;
121122
}
122123
}
@@ -128,7 +129,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
128129
}
129130

130131
private shouldRetry(enableRetry:boolean, currentAttempt:number, maxRetries:number, responseCode:number):boolean{
131-
return (responseCode == 429 || responseCode >=500 ) && maxRetries>currentAttempt && enableRetry
132+
return (responseCode === 429 || responseCode >= 500 ) && maxRetries > currentAttempt && enableRetry
132133
}
133134

134135
private calculateRetryInterval(currentAttempt:number, backoffBase:number, backoffMultiplier:number, headers: {[name: string]: string}) : number{
@@ -165,7 +166,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
165166
: "";
166167
const compress = request.getHttpConfig().compress ?? true;
167168

168-
console.debug(
169+
logger.debug(
169170
"\nrequest: {\n",
170171
`\turl: ${url}\n`,
171172
`\tmethod: ${method}\n`,
@@ -181,7 +182,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
181182
/\n/g,
182183
"\n\t"
183184
);
184-
console.debug(
185+
logger.debug(
185186
"response: {\n",
186187
`\tstatus: ${httpStatusCode}\n`,
187188
`\theaders: ${headers}\n`

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ class HttpLibraryWithProxy implements client.HttpLibrary {
254254

255255
const headers = request.getHeaders();
256256
if (typeof body === "string") {
257-
if (headers["Content-Encoding"] == "gzip") {
257+
if (headers["Content-Encoding"] === "gzip") {
258258
body = bufferFrom(pako.gzip(body).buffer);
259-
} else if (headers["Content-Encoding"] == "deflate") {
259+
} else if (headers["Content-Encoding"] === "deflate") {
260260
body = bufferFrom(pako.deflate(body).buffer);
261261
}
262262
}

features/support/undo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function buildUndoFor(
4747
request: any
4848
): { (): void } {
4949
return async function () {
50-
var apiName = operationUndo.tag.replace(/\s/g, "");
50+
let apiName = operationUndo.tag.replace(/\s/g, "");
5151
if (operationUndo.undo.tag != null) {
5252
apiName = operationUndo.undo.tag.replace(/\s/g, "");
5353
}
@@ -87,7 +87,7 @@ function buildUndoFor(
8787
// perform operation
8888
const opts: { [key: string]: any } = {};
8989
for (const p of operationUndo.undo.parameters) {
90-
var dataSource: { [key: string]: any; };
90+
let dataSource: { [key: string]: any; };
9191
if (p.origin === undefined) {
9292
dataSource = response;
9393
} else if (p.origin === "request") {

packages/datadog-api-client-common/http/isomorphic-fetch.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { fetch as crossFetch } from "cross-fetch";
88
import pako from "pako";
99
import bufferFrom from "buffer-from";
1010
import { isBrowser, isNode } from "../util";
11+
import { logger } from "../../../logger";
1112

1213
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
1314
public debug = false;
@@ -32,11 +33,11 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
3233
const headers = request.getHeaders();
3334

3435
if (typeof body === "string") {
35-
if (headers["Content-Encoding"] == "gzip") {
36+
if (headers["Content-Encoding"] === "gzip") {
3637
body = bufferFrom(pako.gzip(body).buffer);
37-
} else if (headers["Content-Encoding"] == "deflate") {
38+
} else if (headers["Content-Encoding"] === "deflate") {
3839
body = bufferFrom(pako.deflate(body).buffer);
39-
} else if (headers["Content-Encoding"] == "zstd1") {
40+
} else if (headers["Content-Encoding"] === "zstd1") {
4041
if (this.zstdCompressorCallback) {
4142
body = this.zstdCompressorCallback(body);
4243
} else {
@@ -122,7 +123,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
122123
}
123124
return response;
124125
} catch (error) {
125-
console.error("An error occurred during the HTTP request:", error);
126+
logger.error("An error occurred during the HTTP request:", error);
126127
throw error;
127128
}
128129
}
@@ -140,7 +141,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
140141
responseCode: number
141142
): boolean {
142143
return (
143-
(responseCode == 429 || responseCode >= 500) &&
144+
(responseCode === 429 || responseCode >= 500) &&
144145
maxRetries > currentAttempt &&
145146
enableRetry
146147
);
@@ -185,7 +186,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
185186
: "";
186187
const compress = request.getHttpConfig().compress ?? true;
187188

188-
console.debug(
189+
logger.debug(
189190
"\nrequest: {\n",
190191
`\turl: ${url}\n`,
191192
`\tmethod: ${method}\n`,
@@ -201,7 +202,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
201202
/\n/g,
202203
"\n\t"
203204
);
204-
console.debug(
205+
logger.debug(
205206
"response: {\n",
206207
`\tstatus: ${httpStatusCode}\n`,
207208
`\theaders: ${headers}\n`

0 commit comments

Comments
 (0)