Skip to content

Commit

Permalink
feat(detector): id is always equals to the name of the detector class
Browse files Browse the repository at this point in the history
  • Loading branch information
byakuren-hijiri committed May 29, 2024
1 parent 66eee51 commit 24b17f8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/detectors/builtin/readOnlyVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ import { createError, MistiTactError, Severity } from "../../internals/errors";
* Alternatively, identifying read-only variables may reveal issues where unused values are being replaced unintentionally.
*/
export class ReadOnlyVariables extends Detector {
get id(): string {
return "ROV";
}

check(ctx: MistiContext, cu: CompilationUnit): MistiTactError[] {
const program = new Context<ASTRef>(this.id);
this.addDecls(program);
Expand Down
4 changes: 0 additions & 4 deletions src/detectors/builtin/zeroAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ function findZeroAddress(
* result in loss of funds or tokens, as there is no private key to access this address.
*/
export class ZeroAddress extends Detector {
get id(): string {
return "ZeroAddress";
}

check(_ctx: MistiContext, cu: CompilationUnit): MistiTactError[] {
return cu.ast.getProgramEntries().reduce((acc, node) => {
return acc.concat(foldExpressions(node, [], findZeroAddress));
Expand Down
4 changes: 3 additions & 1 deletion src/detectors/detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export abstract class Detector {
* Gets the short identifier of the detector, used in analyzer warnings.
* @returns The unique identifier of the detector.
*/
abstract get id(): string;
get id(): string {
return this.constructor.name;
}

/**
* Executes the detector's logic to check for issues within the provided compilation unit.
Expand Down

0 comments on commit 24b17f8

Please sign in to comment.