Skip to content

Commit

Permalink
Add feature: support x-zally-ignore (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
laohyx committed Mar 8, 2022
1 parent 2f4ee31 commit 53bb3bd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/ethlo/zally/ZallyRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ public class ZallyRunner
{
private final List<RuleDetails> rules;

private final Log logger;

public ZallyRunner(final Config ruleConfigs, final Log logger)
{
this.rules = new LinkedList<>();
this.logger = logger;
final List<Class<?>> ruleClasses = loadRuleClasses();
for (Class<?> ruleClass : ruleClasses)
{
Expand Down Expand Up @@ -117,6 +120,13 @@ private CheckDetails performCheck(Context context, List<Result> violationList, O
//noinspection unchecked
for (Violation violation : (Iterable<? extends Violation>) result)
{
// Ignore violations if there are x-zally-ignore markers.
if (context.isIgnored(violation.getPointer(), checkDetails.getRule().id())
|| context.isIgnored(violation.getPointer(), "*"))
{
logger.info(String.format("Ignore violation, rule = %s, at %s", checkDetails.getRule().id(), violation.getPointer()));
continue;
}
violationList.add(handleViolation(checkDetails, violation));
}
}
Expand Down

0 comments on commit 53bb3bd

Please sign in to comment.