MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / setRule

Method setRule

src/common/configParser.ts:34–49  ·  view source on GitHub ↗
(key: Identifier, rule: Rule, needSave: boolean = true)

Source from the content-addressed store, hash-verified

32 }
33
34 setRule(key: Identifier, rule: Rule, needSave: boolean = true) {
35 if (this.rules.has(key)) {
36 throw `duplicate rule ${key}`;
37 }
38 if (rule.check) {
39 const status = this.normalizeCheckResult(rule.check(rule.predefined));
40 if (!status.canSave) {
41 console.log("invalid predefined", key, rule.predefined);
42 }
43 }
44 rule.needSave = needSave;
45 this.rules.set(key, rule);
46 if (!needSave) {
47 this.notSavingKeys.push(key);
48 }
49 }
50
51 getRule(key: Identifier): Rule {
52 return <Rule>this.rules.get(key);

Callers 1

initConfigFunction · 0.80

Calls 5

normalizeCheckResultMethod · 0.95
checkMethod · 0.80
pushMethod · 0.80
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected