Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #34 from Keyrxng/main
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Mar 14, 2024
2 parents 385a90e + c8a10b6 commit 90d7570
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/handlers/issue/comment-scoring-rubric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,17 @@ export class CommentScoring {
): (typeof CommentScoring.prototype.commentScores)[number]["details"][number]["wordScoreCommentDetails"] {
const wordScoreCommentDetails: { [key: string]: Decimal } = {};

const builtIns = new Set(
Object.getOwnPropertyNames(Object.prototype).filter((name) => typeof Object.prototype[name] === "function")
);

for (const word of words) {
let counter = wordScoreCommentDetails[word] || ZERO;
counter = counter.plus(this.roleWordScore);
wordScoreCommentDetails[word] = counter;
if (!builtIns.has(word)) {
let counter = wordScoreCommentDetails[word] || ZERO;
counter = counter.plus(this.roleWordScore);

wordScoreCommentDetails[word] = counter;
}
}

return wordScoreCommentDetails;
Expand Down
35 changes: 35 additions & 0 deletions src/handlers/tests/scoring-rubric-built-ins.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Decimal from "decimal.js";

describe("Scoring Rubric Built-ins", () => {
let wordScoreCommentDetails: { [key: string]: Decimal };

beforeEach(() => {
wordScoreCommentDetails = {};
});

it("should increment counter for non-built-in words", () => {
const words = ["hasOwnProperty", "valueOf", "was", "async", "but", "the", "constructor", "isn", "t", "I", "was"];
const ZERO = new Decimal(0);

const builtIns = new Set(
Object.getOwnPropertyNames(Object.prototype).filter((name) => typeof Object.prototype[name] === "function")
);

for (const word of words) {
if (!builtIns.has(word)) {
const counter = wordScoreCommentDetails[word] || ZERO;
wordScoreCommentDetails[word] = counter;
}
}

expect(wordScoreCommentDetails).toEqual({
was: new Decimal(0),
async: new Decimal(0),
but: new Decimal(0),
the: new Decimal(0),
isn: new Decimal(0),
t: new Decimal(0),
I: new Decimal(0),
});
});
});
2 changes: 1 addition & 1 deletion src/utils/generate-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function generateConfiguration(
const orgConfig = parseYaml(
await download({
repository: UBIQUIBOT_CONFIG_REPOSITORY,
owner: owner,
owner,
authenticatedOctokit,
})
);
Expand Down

0 comments on commit 90d7570

Please sign in to comment.