diff --git a/eslint.config.mjs b/eslint.config.mjs
index 45f70caf..07a5250b 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -69,6 +69,8 @@ export default tsEslint.config({
"sonarjs/different-types-comparison": "off",
"sonarjs/sonar-prefer-regexp-exec": "off",
"sonarjs/function-return-type": "off",
+ "sonarjs/no-misleading-array-reverse": "off",
+ "sonarjs/slow-regex": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/naming-convention": [
"error",
diff --git a/src/parser/content-evaluator-module.ts b/src/parser/content-evaluator-module.ts
index 8ccadc60..e7a6cc9a 100644
--- a/src/parser/content-evaluator-module.ts
+++ b/src/parser/content-evaluator-module.ts
@@ -87,7 +87,7 @@ export class ContentEvaluatorModule implements Module {
}
_getRewardForComment(comment: GithubCommentScore, relevance: number) {
- let reward = new Decimal(comment?.score?.reward || 0);
+ let reward = new Decimal(comment?.score?.reward ?? 0);
if (comment?.score?.formatting && comment.score.multiplier && comment.score.words) {
let totalRegexReward = new Decimal(0);
diff --git a/src/parser/formatting-evaluator-module.ts b/src/parser/formatting-evaluator-module.ts
index 4137b999..28c7c309 100644
--- a/src/parser/formatting-evaluator-module.ts
+++ b/src/parser/formatting-evaluator-module.ts
@@ -55,8 +55,7 @@ export class FormattingEvaluatorModule implements Module {
for (const key of Object.keys(result)) {
const currentElement = result[key];
const comments = currentElement.comments || [];
- for (let i = 0; i < comments.length; i++) {
- const comment = comments[i];
+ for (const comment of comments) {
const { formatting, words } = this._getFormattingScore(comment);
const multiplierFactor = this._multipliers?.[comment.type] ?? { multiplier: 0 };
const formattingTotal = this._calculateFormattingTotal(formatting, words, multiplierFactor).toDecimalPlaces(2);
@@ -111,13 +110,13 @@ export class FormattingEvaluatorModule implements Module {
const res = this._classifyTagsWithWordCount(temp.window.document.body, comment.type);
return { formatting: res.formatting, words: res.words };
} else {
- throw new Error(`Could not create DOM for comment [${comment}]`);
+ throw new Error(`Could not create DOM for comment [${JSON.stringify(comment)}]`);
}
}
_countWordsFromRegex(text: string, wordValue = 0): WordResult {
const match = text.trim().match(new RegExp(wordRegex, "g"));
- const wordCount = match?.length || 0;
+ const wordCount = match?.length ?? 0;
const result = new Decimal(wordCount).pow(this._wordCountExponent).mul(wordValue).toDecimalPlaces(2).toNumber();
return {
wordCount,
diff --git a/src/parser/github-comment-module.ts b/src/parser/github-comment-module.ts
index b38b1afa..b52d8c66 100644
--- a/src/parser/github-comment-module.ts
+++ b/src/parser/github-comment-module.ts
@@ -222,13 +222,13 @@ export class GithubCommentModule implements Module {
- ${new Decimal(commentScore.score?.words?.result || 0).add(new Decimal(commentScore.score?.formatting?.result || 0))}
+ ${new Decimal(commentScore.score?.words?.result ?? 0).add(new Decimal(commentScore.score?.formatting?.result ?? 0))}
${formatting}
|
- ${commentScore.score?.relevance || "-"} |
- ${commentScore.score?.reward || "-"} |
+ ${commentScore.score?.relevance ?? "-"} |
+ ${commentScore.score?.reward ?? "-"} |
`;
}
diff --git a/src/parser/permit-generation-module.ts b/src/parser/permit-generation-module.ts
index 0d3dc804..86fb82bc 100644
--- a/src/parser/permit-generation-module.ts
+++ b/src/parser/permit-generation-module.ts
@@ -45,7 +45,7 @@ export class PermitGenerationModule implements Module {
evmNetworkId: configuration.evmNetworkId,
erc20RewardToken: configuration.erc20RewardToken,
};
- const issueId = Number(payload.issueUrl.match(/[0-9]+$/)?.[0]);
+ const issueId = Number(payload.issueUrl.match(/\d+$/)?.[0]);
payload.issue = {
node_id: program.eventPayload.issue.node_id,
};
@@ -192,7 +192,7 @@ export class PermitGenerationModule implements Module {
// - user.comments[].reward
const feeRateDecimal = new Decimal(100).minus(env.PERMIT_FEE_RATE).div(100);
let permitFeeAmountDecimal = new Decimal(0);
- for (const [_, rewardResult] of Object.entries(result)) {
+ for (const [, rewardResult] of Object.entries(result)) {
// accumulate total permit fee amount
const totalAfterFee = new Decimal(rewardResult.total).mul(feeRateDecimal).toNumber();
permitFeeAmountDecimal = permitFeeAmountDecimal.add(new Decimal(rewardResult.total).minus(totalAfterFee));
@@ -250,7 +250,7 @@ export class PermitGenerationModule implements Module {
locationId = locationData.id;
}
if (!locationId) {
- throw new Error(`Failed to retrieve the related location from issue ${issue}`);
+ throw new Error(`Failed to retrieve the related location from issue ${JSON.stringify(issue)}`);
}
return locationId;
}
diff --git a/src/parser/user-extractor-module.ts b/src/parser/user-extractor-module.ts
index 6dd1649f..400014d0 100644
--- a/src/parser/user-extractor-module.ts
+++ b/src/parser/user-extractor-module.ts
@@ -44,7 +44,7 @@ export class UserExtractorModule implements Module {
}
_getTaskMultiplier(issue: GitHubIssue) {
- return new Decimal(1).div(issue.assignees?.length || 1);
+ return new Decimal(1).div(issue.assignees?.length ?? 1);
}
async transform(data: Readonly, result: Result): Promise {
diff --git a/tests/__mocks__/@octokit/plugin-paginate-graphql.js b/tests/__mocks__/@octokit/plugin-paginate-graphql.js
index f2b2980a..8bccb1fc 100644
--- a/tests/__mocks__/@octokit/plugin-paginate-graphql.js
+++ b/tests/__mocks__/@octokit/plugin-paginate-graphql.js
@@ -1,3 +1,5 @@
+/* eslint-disable */
+
module.exports = {
paginateGraphQL() {
return {
diff --git a/tests/process.issue.test.ts b/tests/process.issue.test.ts
index 7e37e94c..8d1e9a2c 100644
--- a/tests/process.issue.test.ts
+++ b/tests/process.issue.test.ts
@@ -1,3 +1,5 @@
+/* eslint-disable sonarjs/no-nested-functions */
+
import fs from "fs";
import { http, HttpResponse } from "msw";
import configuration from "../src/configuration/config-reader";
diff --git a/tests/rewards.test.ts b/tests/rewards.test.ts
index 67ac8975..dfef6721 100644
--- a/tests/rewards.test.ts
+++ b/tests/rewards.test.ts
@@ -1,3 +1,5 @@
+/* eslint-disable sonarjs/no-nested-functions */
+
import { drop } from "@mswjs/data";
import fs from "fs";
import { http, HttpResponse } from "msw";
diff --git a/tests/truncate-data.test.ts b/tests/truncate-data.test.ts
index 3f2ff675..62638ce3 100644
--- a/tests/truncate-data.test.ts
+++ b/tests/truncate-data.test.ts
@@ -1,3 +1,4 @@
+/* eslint-disable sonarjs/no-nested-functions */
import { drop } from "@mswjs/data";
import "../src/parser/command-line";
import { db } from "./__mocks__/db";