Skip to content

Commit 7e45488

Browse files
author
h1alexbel
committed
feat(#38): field declaration move to ctor, GitHub typo
1 parent 7246372 commit 7e45488

File tree

10 files changed

+92
-148
lines changed

10 files changed

+92
-148
lines changed

src/chat-gpt.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,15 @@ import OpenAI from "openai";
3232
*/
3333
export class ChatGpt implements Model {
3434

35-
/**
36-
* Open AI.
37-
*/
38-
private readonly open: OpenAI;
39-
40-
/**
41-
* Model name.
42-
*/
43-
private readonly model: string;
44-
4535
/**
4636
* Ctor.
4737
* @param open Open AI
4838
* @param model Model name
4939
*/
50-
constructor(open: OpenAI, model: string) {
40+
constructor(
41+
private readonly open: OpenAI,
42+
private readonly model: string
43+
) {
5144
this.open = open;
5245
this.model = model;
5346
}

src/comment.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,16 @@ import {Octokit} from "@octokit/rest";
2828
*/
2929
export class Comment {
3030

31-
/**
32-
* Github.
33-
*/
34-
private readonly github: Octokit;
35-
36-
/**
37-
* Issue.
38-
*/
39-
private readonly issue: Issue;
40-
41-
/**
42-
* Text to post.
43-
*/
44-
private readonly text: string;
45-
4631
/**
4732
* Ctor.
48-
* @param github Github
33+
* @param github GitHub
4934
* @param issue Issue
5035
* @param text Text
5136
*/
5237
constructor(
53-
github: Octokit,
54-
issue: Issue,
55-
text: string
38+
private readonly github: Octokit,
39+
private readonly issue: Issue,
40+
private readonly text: string
5641
) {
5742
this.github = github;
5843
this.issue = issue;

src/covered.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,14 @@
2323
*/
2424
export class Covered {
2525

26-
/**
27-
* Username.
28-
*/
29-
private readonly username;
30-
31-
/**
32-
* Message.
33-
*/
34-
private readonly message: string;
35-
3626
/**
3727
* Ctor.
3828
* @param username Username
3929
* @param message Message
4030
*/
4131
constructor(
42-
username: string | undefined,
43-
message: string
32+
private readonly username: string | undefined,
33+
private readonly message: string
4434
) {
4535
this.username = username;
4636
this.message = message;

src/deep-infra.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,15 @@ import {Rules} from "./rules";
3131
*/
3232
export class DeepInfra implements Model {
3333

34-
/**
35-
* API Key.
36-
*/
37-
private readonly token: string;
38-
39-
/**
40-
* Model.
41-
*/
42-
private readonly model: string;
43-
4434
/**
4535
* Ctor.
4636
* @param token Token
4737
* @param model Model
4838
*/
49-
constructor(token: string, model: string) {
39+
constructor(
40+
private readonly token: string,
41+
private readonly model: string
42+
) {
5043
this.token = token;
5144
this.model = model;
5245
}

src/feedback.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,18 @@ import {NonRelevant} from "./non-relevant";
3333
*/
3434
export class Feedback {
3535

36-
/**
37-
* Summary.
38-
*/
39-
private readonly summary: string | undefined;
40-
41-
/**
42-
* GitHub.
43-
*/
44-
private readonly github: Octokit;
45-
46-
/**
47-
* Issue.
48-
*/
49-
private readonly issue: Issue;
50-
51-
/**
52-
* Username.
53-
*/
54-
private readonly username: string | undefined;
55-
5636
/**
5737
* Ctor.
5838
* @param summary Summary
59-
* @param github Github
39+
* @param github GitHub
6040
* @param issue Issue
6141
* @param username Username
6242
*/
6343
constructor(
64-
summary: string | undefined,
65-
github: Octokit,
66-
issue: Issue,
67-
username: string | undefined
44+
private readonly summary: string | undefined,
45+
private readonly github: Octokit,
46+
private readonly issue: Issue,
47+
private readonly username: string | undefined
6848
) {
6949
this.summary = summary;
7050
this.github = github;

src/label.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2023-2024 Tracehub.git
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included
14+
* in all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
import {Octokit} from "@octokit/rest";
25+
26+
/**
27+
* GitHub label.
28+
*/
29+
export class Label {
30+
31+
/**
32+
* Ctor.
33+
* @param github GitHub
34+
* @param issue Issue
35+
* @param label Label
36+
*/
37+
constructor(
38+
private readonly github: Octokit,
39+
private readonly issue: Issue,
40+
private readonly label: string) {
41+
}
42+
43+
/**
44+
* Attach label.
45+
*/
46+
async attach() {
47+
await this.github.issues.addLabels(
48+
{
49+
owner: this.issue.owner,
50+
repo: this.issue.repo,
51+
issue_number: this.issue.number,
52+
labels: [this.label]
53+
}
54+
);
55+
}
56+
}

src/non-relevant.ts

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,23 @@
2323
*/
2424
import {Octokit} from "@octokit/rest";
2525
import {Comment} from "./comment";
26+
import {Label} from "./label";
2627

2728
/**
2829
* Non Relevant bug report.
2930
*/
3031
export class NonRelevant {
3132

32-
/**
33-
* Github.
34-
*/
35-
private readonly github: Octokit;
36-
37-
/**
38-
* Issue.
39-
*/
40-
private readonly issue: Issue;
41-
42-
/**
43-
* Creator.
44-
*/
45-
private readonly creator: string | undefined;
46-
4733
/**
4834
* Ctor.
4935
* @param github Github
5036
* @param issue Issue
5137
* @param creator Creator
5238
*/
5339
constructor(
54-
github: Octokit,
55-
issue: Issue,
56-
creator: string | undefined
40+
private readonly github: Octokit,
41+
private readonly issue: Issue,
42+
private readonly creator: string | undefined
5743
) {
5844
this.github = github;
5945
this.issue = issue;
@@ -71,14 +57,7 @@ export class NonRelevant {
7157
+ " this issue is not relevant to " + "\`" + this.issue.owner + "/" + this.issue.repo + "\`" + "."
7258
+ " We should close it."
7359
).post();
74-
await this.github.issues.addLabels(
75-
{
76-
owner: this.issue.owner,
77-
repo: this.issue.repo,
78-
issue_number: this.issue.number,
79-
labels: ["invalid"]
80-
}
81-
);
60+
await new Label(this.github, this.issue, "invalid").attach();
8261
await this.github.issues.update(
8362
{
8463
owner: this.issue.owner,

src/smart-issue.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,14 @@ import {Octokit} from "@octokit/rest";
3030
*/
3131
export class SmartIssue {
3232

33-
/**
34-
* Github.
35-
*/
36-
private readonly github: Octokit;
37-
38-
/**
39-
* Issue.
40-
*/
41-
private readonly issue: {
42-
owner: string,
43-
repo: string,
44-
number: number
45-
};
46-
4733
/**
4834
* Ctor.
49-
* @param github Github
35+
* @param github GitHub
5036
* @param issue Issue
5137
*/
5238
constructor(
53-
github: Octokit,
54-
issue: {
39+
private readonly github: Octokit,
40+
private readonly issue: {
5541
owner: string,
5642
repo: string,
5743
number: number

src/user-prompt.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,18 @@ import {Rules} from "./rules";
2929
*/
3030
export class UserPrompt {
3131

32-
/**
33-
* Example.
34-
*/
35-
private readonly example: Example;
36-
37-
/**
38-
* Rules.
39-
*/
40-
private readonly rules: Rules;
41-
42-
/**
43-
* Bug report.
44-
*/
45-
private readonly report: string | null | undefined;
46-
4732
/**
4833
* Ctor.
4934
*
5035
* @param example Example
5136
* @param rules Rules
5237
* @param report Bug report
5338
*/
54-
constructor(example: Example, rules: Rules, report: string | null | undefined) {
39+
constructor(
40+
private readonly example: Example,
41+
private readonly rules: Rules,
42+
private readonly report: string | null | undefined
43+
) {
5544
this.example = example;
5645
this.rules = rules;
5746
this.report = report;

src/with-summary.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,15 @@ import {Covered} from "./covered";
2828
*/
2929
export class WithSummary {
3030

31-
/**
32-
* Origin.
33-
*/
34-
private readonly origin: Covered;
35-
36-
/**
37-
* Summary.
38-
*/
39-
private readonly summary: string | undefined;
40-
4131
/**
4232
* Ctor.
4333
* @param origin Origin
4434
* @param summary Summary
4535
*/
46-
constructor(origin: Covered, summary: string | undefined) {
36+
constructor(
37+
private readonly origin: Covered,
38+
private readonly summary: string | undefined
39+
) {
4740
this.origin = origin;
4841
this.summary = summary;
4942
}

0 commit comments

Comments
 (0)