@@ -39,14 +39,14 @@ Map<String, RuleFunction> get supportedRules => {
3939 'references-empty' : emptyRule (CommitComponent .references),
4040 };
4141
42- /// Build fullstop rule for commit component.
42+ /// Build full- stop rule for commit component.
4343RuleFunction fullStopRule (CommitComponent component) {
4444 return (Commit commit, Rule config) {
4545 if (config is ! ValueRule ) {
4646 throw Exception ('$config is not ValueRuleConfig<String>' );
4747 }
4848 final raw = commit.componentRaw (component);
49- final result = raw != null && ensureFullStop (raw, config.value);
49+ final result = raw == null || ensureFullStop (raw, config.value);
5050 final negated = config.condition == RuleCondition .never;
5151 return RuleOutcome (
5252 valid: negated ? ! result : result,
@@ -59,11 +59,11 @@ RuleFunction fullStopRule(CommitComponent component) {
5959 };
6060}
6161
62- /// Build leandingblank rule for commit component.
62+ /// Build leanding- blank rule for commit component.
6363RuleFunction leadingBlankRule (CommitComponent component) {
6464 return (Commit commit, Rule config) {
6565 final raw = commit.componentRaw (component);
66- final result = raw != null && ensureLeadingBlank (raw);
66+ final result = raw == null || ensureLeadingBlank (raw);
6767 final negated = config.condition == RuleCondition .never;
6868 return RuleOutcome (
6969 valid: negated ? ! result : result,
@@ -76,11 +76,11 @@ RuleFunction leadingBlankRule(CommitComponent component) {
7676 };
7777}
7878
79- /// Build leanding blank rule for commit component.
79+ /// Build empty rule for commit component.
8080RuleFunction emptyRule (CommitComponent component) {
8181 return (Commit commit, Rule config) {
8282 final raw = commit.componentRaw (component);
83- final result = ensureEmpty (raw);
83+ final result = raw == null || ensureEmpty (raw);
8484 final negated = config.condition == RuleCondition .never;
8585 return RuleOutcome (
8686 valid: negated ? ! result : result,
@@ -97,7 +97,7 @@ RuleFunction caseRule(CommitComponent component) {
9797 throw Exception ('$config is not CaseRuleConfig' );
9898 }
9999 final raw = commit.componentRaw (component);
100- final result = raw != null && ensureCase (raw, config.type);
100+ final result = raw == null || ensureCase (raw, config.type);
101101 final negated = config.condition == RuleCondition .never;
102102 return RuleOutcome (
103103 valid: negated ? ! result : result,
@@ -110,14 +110,14 @@ RuleFunction caseRule(CommitComponent component) {
110110 };
111111}
112112
113- /// Build maxlength rule for commit component.
113+ /// Build max- length rule for commit component.
114114RuleFunction maxLengthRule (CommitComponent component) {
115115 return (Commit commit, Rule config) {
116116 if (config is ! LengthRule ) {
117117 throw Exception ('$config is not LengthRuleConfig' );
118118 }
119119 final raw = commit.componentRaw (component);
120- final result = raw != null && ensureMaxLength (raw, config.length);
120+ final result = raw == null || ensureMaxLength (raw, config.length);
121121 final negated = config.condition == RuleCondition .never;
122122 return RuleOutcome (
123123 valid: negated ? ! result : result,
@@ -130,14 +130,14 @@ RuleFunction maxLengthRule(CommitComponent component) {
130130 };
131131}
132132
133- /// Build maxlinelength rule for commit component.
133+ /// Build max- line- length rule for commit component.
134134RuleFunction maxLineLengthRule (CommitComponent component) {
135135 return (Commit commit, Rule config) {
136136 if (config is ! LengthRule ) {
137137 throw Exception ('$config is not LengthRuleConfig' );
138138 }
139139 final raw = commit.componentRaw (component);
140- final result = raw != null && ensureMaxLineLength (raw, config.length);
140+ final result = raw == null || ensureMaxLineLength (raw, config.length);
141141 final negated = config.condition == RuleCondition .never;
142142 return RuleOutcome (
143143 valid: negated ? ! result : result,
@@ -150,14 +150,14 @@ RuleFunction maxLineLengthRule(CommitComponent component) {
150150 };
151151}
152152
153- /// Build minlength rule for commit component.
153+ /// Build min- length rule for commit component.
154154RuleFunction minLengthRule (CommitComponent component) {
155155 return (Commit commit, Rule config) {
156156 if (config is ! LengthRule ) {
157157 throw Exception ('$config is not LengthRuleConfig' );
158158 }
159159 final raw = commit.componentRaw (component);
160- final result = raw != null && ensureMinLength (raw, config.length);
160+ final result = raw == null || ensureMinLength (raw, config.length);
161161 final negated = config.condition == RuleCondition .never;
162162 return RuleOutcome (
163163 valid: negated ? ! result : result,
@@ -170,13 +170,14 @@ RuleFunction minLengthRule(CommitComponent component) {
170170 };
171171}
172172
173+ /// Build enum rule for commit component.
173174RuleFunction enumRule (CommitComponent component) {
174175 return (Commit commit, Rule config) {
175176 if (config is ! EnumRule ) {
176177 throw Exception ('$config is not EnumRuleConfig' );
177178 }
178179 final raw = commit.componentRaw (component);
179- final result = ensureEnum (raw, config.allowed);
180+ final result = raw == null || ensureEnum (raw, config.allowed);
180181 final negated = config.condition == RuleCondition .never;
181182 return RuleOutcome (
182183 valid: negated ? ! result : result,
0 commit comments