Skip to content

Commit

Permalink
removed debug rule (paritytech#68)
Browse files Browse the repository at this point in the history
This rule is no longer in use an can be removed
  • Loading branch information
Bullrich authored Sep 5, 2023
1 parent d8b2e9f commit 4fbe062
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
9 changes: 1 addition & 8 deletions src/rules/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum RuleTypes {
Basic = "basic",
Debug = "debug",
And = "and",
Or = "or",
AndDistinct = "and-distinct",
Expand All @@ -14,12 +13,6 @@ export interface Rule {
countAuthor?: boolean;
}

// TODO: Delete this once we add a second type of rule
export interface DebugRule extends Rule {
type: RuleTypes.Debug;
size: number;
}

export interface BasicRule extends Rule, Reviewers {
type: RuleTypes.Basic;
}
Expand All @@ -43,7 +36,7 @@ export interface ConfigurationFile {
/** Based on the `type` parameter, Typescript converts the object to the correct type
* @see {@link Rules}
*/
rules: (BasicRule | DebugRule | AndRule | OrRule | AndDistinctRule)[];
rules: (BasicRule | AndRule | OrRule | AndDistinctRule)[];
preventReviewRequests?: {
teams?: string[];
users?: string[];
Expand Down
8 changes: 2 additions & 6 deletions src/rules/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { validate } from "@eng-automation/js";
import Joi from "joi";

import { ActionLogger } from "../github/types";
import { AndRule, BasicRule, ConfigurationFile, DebugRule, Reviewers, Rule, RuleTypes } from "./types";
import { AndRule, BasicRule, ConfigurationFile, Reviewers, Rule, RuleTypes } from "./types";

/** For the users or team schema. Will be recycled A LOT
* Remember to add `.or("users", "teams")` to force at least one of the two to be defined
Expand All @@ -24,9 +24,7 @@ const ruleSchema = Joi.object<Rule & { type: string }>().keys({
include: Joi.array().items(Joi.string()).required(),
exclude: Joi.array().items(Joi.string()).optional().allow(null),
}),
type: Joi.string()
.valid(RuleTypes.Basic, RuleTypes.Debug, RuleTypes.And, RuleTypes.Or, RuleTypes.AndDistinct)
.required(),
type: Joi.string().valid(RuleTypes.Basic, RuleTypes.And, RuleTypes.Or, RuleTypes.AndDistinct).required(),
});

/** General Configuration schema.
Expand Down Expand Up @@ -73,8 +71,6 @@ export const validateConfig = (config: ConfigurationFile): ConfigurationFile | n
const message = `Configuration for rule '${rule.name}' is invalid`;
if (type === "basic") {
validatedConfig.rules[i] = validate<BasicRule>(rule, basicRuleSchema, { message });
} else if (type === "debug") {
validatedConfig.rules[i] = validate<DebugRule>(rule, ruleSchema, { message });
} else if (type === "and" || type === "or" || type === "and-distinct") {
// Aside from the type, every other field in this rules is identical so we can
// use any of these rules to validate the other fields.
Expand Down
2 changes: 1 addition & 1 deletion src/test/rules/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe("Config Parsing", () => {
teams:
- team-example
`);
// prettifies string to [basic, debug, and, or...]
// prettifies string to [basic, and, or...]
const types = JSON.stringify(Object.values(RuleTypes)).replace(/"/g, "").replace(/,/g, ", ");
await expect(runner.getConfigFile("")).rejects.toThrowError(
'Configuration file is invalid: "rules[0].type" must be one of ' + types,
Expand Down

0 comments on commit 4fbe062

Please sign in to comment.