@@ -39,14 +39,14 @@ Map<String, RuleFunction> get supportedRules => {
39
39
'references-empty' : emptyRule (CommitComponent .references),
40
40
};
41
41
42
- /// Build full stop rule for commit component.
42
+ /// Build full- stop rule for commit component.
43
43
RuleFunction fullStopRule (CommitComponent component) {
44
44
return (Commit commit, Rule config) {
45
45
if (config is ! ValueRule ) {
46
46
throw Exception ('$config is not ValueRuleConfig<String>' );
47
47
}
48
48
final raw = commit.componentRaw (component);
49
- final result = raw != null && ensureFullStop (raw, config.value);
49
+ final result = raw == null || ensureFullStop (raw, config.value);
50
50
final negated = config.condition == RuleCondition .never;
51
51
return RuleOutcome (
52
52
valid: negated ? ! result : result,
@@ -59,11 +59,11 @@ RuleFunction fullStopRule(CommitComponent component) {
59
59
};
60
60
}
61
61
62
- /// Build leanding blank rule for commit component.
62
+ /// Build leanding- blank rule for commit component.
63
63
RuleFunction leadingBlankRule (CommitComponent component) {
64
64
return (Commit commit, Rule config) {
65
65
final raw = commit.componentRaw (component);
66
- final result = raw != null && ensureLeadingBlank (raw);
66
+ final result = raw == null || ensureLeadingBlank (raw);
67
67
final negated = config.condition == RuleCondition .never;
68
68
return RuleOutcome (
69
69
valid: negated ? ! result : result,
@@ -76,11 +76,11 @@ RuleFunction leadingBlankRule(CommitComponent component) {
76
76
};
77
77
}
78
78
79
- /// Build leanding blank rule for commit component.
79
+ /// Build empty rule for commit component.
80
80
RuleFunction emptyRule (CommitComponent component) {
81
81
return (Commit commit, Rule config) {
82
82
final raw = commit.componentRaw (component);
83
- final result = ensureEmpty (raw);
83
+ final result = raw == null || ensureEmpty (raw);
84
84
final negated = config.condition == RuleCondition .never;
85
85
return RuleOutcome (
86
86
valid: negated ? ! result : result,
@@ -97,7 +97,7 @@ RuleFunction caseRule(CommitComponent component) {
97
97
throw Exception ('$config is not CaseRuleConfig' );
98
98
}
99
99
final raw = commit.componentRaw (component);
100
- final result = raw != null && ensureCase (raw, config.type);
100
+ final result = raw == null || ensureCase (raw, config.type);
101
101
final negated = config.condition == RuleCondition .never;
102
102
return RuleOutcome (
103
103
valid: negated ? ! result : result,
@@ -110,14 +110,14 @@ RuleFunction caseRule(CommitComponent component) {
110
110
};
111
111
}
112
112
113
- /// Build max length rule for commit component.
113
+ /// Build max- length rule for commit component.
114
114
RuleFunction maxLengthRule (CommitComponent component) {
115
115
return (Commit commit, Rule config) {
116
116
if (config is ! LengthRule ) {
117
117
throw Exception ('$config is not LengthRuleConfig' );
118
118
}
119
119
final raw = commit.componentRaw (component);
120
- final result = raw != null && ensureMaxLength (raw, config.length);
120
+ final result = raw == null || ensureMaxLength (raw, config.length);
121
121
final negated = config.condition == RuleCondition .never;
122
122
return RuleOutcome (
123
123
valid: negated ? ! result : result,
@@ -130,14 +130,14 @@ RuleFunction maxLengthRule(CommitComponent component) {
130
130
};
131
131
}
132
132
133
- /// Build max line length rule for commit component.
133
+ /// Build max- line- length rule for commit component.
134
134
RuleFunction maxLineLengthRule (CommitComponent component) {
135
135
return (Commit commit, Rule config) {
136
136
if (config is ! LengthRule ) {
137
137
throw Exception ('$config is not LengthRuleConfig' );
138
138
}
139
139
final raw = commit.componentRaw (component);
140
- final result = raw != null && ensureMaxLineLength (raw, config.length);
140
+ final result = raw == null || ensureMaxLineLength (raw, config.length);
141
141
final negated = config.condition == RuleCondition .never;
142
142
return RuleOutcome (
143
143
valid: negated ? ! result : result,
@@ -150,14 +150,14 @@ RuleFunction maxLineLengthRule(CommitComponent component) {
150
150
};
151
151
}
152
152
153
- /// Build min length rule for commit component.
153
+ /// Build min- length rule for commit component.
154
154
RuleFunction minLengthRule (CommitComponent component) {
155
155
return (Commit commit, Rule config) {
156
156
if (config is ! LengthRule ) {
157
157
throw Exception ('$config is not LengthRuleConfig' );
158
158
}
159
159
final raw = commit.componentRaw (component);
160
- final result = raw != null && ensureMinLength (raw, config.length);
160
+ final result = raw == null || ensureMinLength (raw, config.length);
161
161
final negated = config.condition == RuleCondition .never;
162
162
return RuleOutcome (
163
163
valid: negated ? ! result : result,
@@ -170,13 +170,14 @@ RuleFunction minLengthRule(CommitComponent component) {
170
170
};
171
171
}
172
172
173
+ /// Build enum rule for commit component.
173
174
RuleFunction enumRule (CommitComponent component) {
174
175
return (Commit commit, Rule config) {
175
176
if (config is ! EnumRule ) {
176
177
throw Exception ('$config is not EnumRuleConfig' );
177
178
}
178
179
final raw = commit.componentRaw (component);
179
- final result = ensureEnum (raw, config.allowed);
180
+ final result = raw == null || ensureEnum (raw, config.allowed);
180
181
final negated = config.condition == RuleCondition .never;
181
182
return RuleOutcome (
182
183
valid: negated ? ! result : result,
0 commit comments