Skip to content

Commit dfbb084

Browse files
committed
rm dynamic loading
1 parent e396728 commit dfbb084

File tree

5 files changed

+13
-60
lines changed

5 files changed

+13
-60
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ out
1919
# generated reports
2020
reports
2121
coverage
22-
.nyc_output
22+
.nyc_output
23+
.github/.secrets

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { IRulesConfig } from "./main/interfaces/IRulesConfig";
33

44
import { Compiler } from "./main/libs/Compiler";
55
import { fix } from "./main/libs/FixFlows";
6-
import { getBetaRules, getRules } from "./main/libs/GetRuleDefinitions";
6+
import { getRules } from "./main/libs/GetRuleDefinitions";
77
import { parse } from "./main/libs/ParseFlows";
88
import { scan } from "./main/libs/ScanFlows";
99
import { AdvancedRule } from "./main/models/AdvancedRule";
@@ -30,7 +30,6 @@ export {
3030
FlowResource,
3131
FlowType,
3232
FlowVariable,
33-
getBetaRules,
3433
getRules,
3534
parse,
3635
ParsedFlow,

src/main/libs/DynamicRule.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { IRuleDefinition } from "../interfaces/IRuleDefinition";
22
import { AdvancedRule } from "../models/AdvancedRule";
3-
import { BetaRuleStore, DefaultRuleStore } from "../store/DefaultRuleStore";
3+
import { DefaultRuleStore } from "../store/DefaultRuleStore";
44

55
export class DynamicRule<T extends AdvancedRule | IRuleDefinition> {
66
constructor(className: string) {
7-
if (!DefaultRuleStore.hasOwnProperty(className) && BetaRuleStore.hasOwnProperty(className)) {
8-
return new BetaRuleStore[className]() as T;
7+
if (!DefaultRuleStore.hasOwnProperty(className)) {
8+
throw new Error(`Class type of \'${className}\' is not in the store`);
99
}
1010
return new DefaultRuleStore[className]() as T;
1111
}
1212
}
13+
Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { IRuleDefinition } from "../interfaces/IRuleDefinition";
2-
import { BetaRuleStore, DefaultRuleStore } from "../store/DefaultRuleStore";
2+
import { DefaultRuleStore } from "../store/DefaultRuleStore";
33
import { DynamicRule } from "./DynamicRule";
4-
import { RuleLoader } from "./RuleLoader";
54

65
export function GetRuleDefinitions(ruleConfig?: Map<string, unknown>): IRuleDefinition[] {
76
const selectedRules: IRuleDefinition[] = [];
87
if (ruleConfig && ruleConfig instanceof Map) {
98
for (const ruleName of ruleConfig.keys()) {
109
let severity = "error";
1110
try {
12-
const configuredPath = ruleConfig.get(ruleName)?.["path"];
1311
const configuredSeverity = ruleConfig.get(ruleName)?.["severity"];
1412
if (
1513
configuredSeverity &&
@@ -19,19 +17,12 @@ export function GetRuleDefinitions(ruleConfig?: Map<string, unknown>): IRuleDefi
1917
) {
2018
severity = configuredSeverity;
2119
}
22-
if (configuredPath) {
23-
const customRule = RuleLoader.loadCustomRule(ruleName, configuredPath) as IRuleDefinition;
24-
if (configuredSeverity) {
25-
customRule.severity = severity;
26-
}
27-
selectedRules.push(customRule);
28-
} else {
29-
const matchedRule = new DynamicRule(ruleName) as IRuleDefinition;
30-
if (configuredSeverity) {
31-
matchedRule.severity = severity;
32-
}
33-
selectedRules.push(matchedRule);
20+
const matchedRule = new DynamicRule(ruleName) as IRuleDefinition;
21+
if (configuredSeverity) {
22+
matchedRule.severity = severity;
3423
}
24+
selectedRules.push(matchedRule);
25+
3526
} catch (error) {
3627
console.log(error.message);
3728
}
@@ -55,10 +46,3 @@ export function getRules(ruleNames?: string[]): IRuleDefinition[] {
5546
}
5647
}
5748

58-
export function getBetaRules(): IRuleDefinition[] {
59-
return getBetaDefinition();
60-
}
61-
62-
function getBetaDefinition(): IRuleDefinition[] {
63-
return Object.values(BetaRuleStore).map((rule) => new rule() as IRuleDefinition);
64-
}

src/main/libs/RuleLoader.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)