Repository: reviewdog/reviewdog
Pull request #691 (2020-07-25 11:50:30)

Refactoring: filter package
- [x] Updated Unreleased section in [CHANGELOG](https://github.com/reviewdog/reviewdog/blob/master/CHANGELOG.md) or it's not notable changes.




Patch:
diff --git a/cmd/reviewdog/doghouse.go b/cmd/reviewdog/doghouse.go
index 6fbda8bb..19ee9f27 100644
--- a/cmd/reviewdog/doghouse.go
+++ b/cmd/reviewdog/doghouse.go
@@ -8,7 +8,6 @@ import (
 	"log"
 	"net/http"
 	"os"
-	"path/filepath"
 	"sort"
 
 	"golang.org/x/oauth2"
@@ -18,6 +17,7 @@ import (
 	"github.com/reviewdog/reviewdog/cienv"
 	"github.com/reviewdog/reviewdog/doghouse"
 	"github.com/reviewdog/reviewdog/doghouse/client"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/project"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 	"github.com/reviewdog/reviewdog/service/github/githubutils"
@@ -156,7 +156,7 @@ func postResultSet(ctx context.Context, resultSet *reviewdog.ResultMap,
 				// it failed to report results with Check API.
 				filteredResultSet.Store(name, &reviewdog.FilteredResult{
 					Level:         result.Level,
-					FilteredCheck: res.CheckedResults,
+					FilteredDiagnostic: res.CheckedResults,
 				})
 			}
 			if res.ReportURL == "" && res.CheckedResults == nil {
@@ -179,8 +179,7 @@ func postResultSet(ctx context.Context, resultSet *reviewdog.ResultMap,
 }
 
 func checkResultToAnnotation(d *rdf.Diagnostic, wd, gitRelWd string) *doghouse.Annotation {
-	d.GetLocation().Path = filepath.ToSlash(filepath.Join(
-		gitRelWd, reviewdog.CleanPath(d.GetLocation().GetPath(), wd)))
+	d.GetLocation().Path = filter.NormalizePath(d.GetLocation().GetPath(), wd, gitRelWd)
 	return &doghouse.Annotation{
 		Diagnostic: d,
 	}
@@ -218,7 +217,7 @@ report results via logging command [1].
 		fmt.Fprintf(w, "reviewdog: Reporting results for %q\n", name)
 		foundResultPerName := false
 		filteredNum := 0
-		for _, result := range results.FilteredCheck {
+		for _, result := range results.FilteredDiagnostic {
 			if !result.ShouldReport {
 				filteredNum++
 				continue
diff --git a/cmd/reviewdog/main.go b/cmd/reviewdog/main.go
index 0d6d0c98..47e03100 100644
--- a/cmd/reviewdog/main.go
+++ b/cmd/reviewdog/main.go
@@ -27,7 +27,7 @@ import (
 	"github.com/reviewdog/reviewdog"
 	"github.com/reviewdog/reviewdog/cienv"
 	"github.com/reviewdog/reviewdog/commands"
-	"github.com/reviewdog/reviewdog/difffilter"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/parser"
 	"github.com/reviewdog/reviewdog/project"
 	gerritservice "github.com/reviewdog/reviewdog/service/gerrit"
@@ -57,7 +57,7 @@ type option struct {
 	level            string
 	guessPullRequest bool
 	tee              bool
-	filterMode       difffilter.Mode
+	filterMode       filter.Mode
 	failOnError      bool
 }
 
@@ -335,7 +335,7 @@ github-pr-check reporter as a fallback.
 		}
 		ds = d
 	case "local":
-		if opt.diffCmd == "" && opt.filterMode == difffilter.ModeNoFilter {
+		if opt.diffCmd == "" && opt.filterMode == filter.ModeNoFilter {
 			ds = &reviewdog.EmptyDiff{}
 		} else {
 			d, err := diffService(opt.diffCmd, opt.diffStrip)
diff --git a/doghouse/server/doghouse.go b/doghouse/server/doghouse.go
index acd210b9..0dc33744 100644
--- a/doghouse/server/doghouse.go
+++ b/doghouse/server/doghouse.go
@@ -10,10 +10,9 @@ import (
 
 	"github.com/google/go-github/v32/github"
 
-	"github.com/reviewdog/reviewdog"
 	"github.com/reviewdog/reviewdog/diff"
-	"github.com/reviewdog/reviewdog/difffilter"
 	"github.com/reviewdog/reviewdog/doghouse"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 	"github.com/reviewdog/reviewdog/service/github/githubutils"
 )
@@ -56,9 +55,9 @@ func (ch *Checker) Check(ctx context.Context) (*doghouse.CheckResponse, error) {
 	if ch.req.PullRequest == 0 || ch.req.OutsideDiff {
 		// If it's not Pull Request run, do not filter results by diff regardless
 		// of the filter mode.
-		filterMode = difffilter.ModeNoFilter
+		filterMode = filter.ModeNoFilter
 	}
-	filtered := reviewdog.FilterCheck(results, filediffs, 1, "", filterMode)
+	filtered := filter.FilterCheck(results, filediffs, 1, "", filterMode)
 	check, err := ch.createCheck(ctx)
 	if err != nil {
 		// If this error is StatusForbidden (403) here, it means reviewdog is
@@ -84,7 +83,7 @@ func (ch *Checker) Check(ctx context.Context) (*doghouse.CheckResponse, error) {
 	return res, nil
 }
 
-func (ch *Checker) postCheck(ctx context.Context, checkID int64, checks []*reviewdog.FilteredCheck) (*github.CheckRun, string, error) {
+func (ch *Checker) postCheck(ctx context.Context, checkID int64, checks []*filter.FilteredDiagnostic) (*github.CheckRun, string, error) {
 	var annotations []*github.CheckRunAnnotation
 	for _, c := range checks {
 		if !c.ShouldReport {
@@ -195,12 +194,12 @@ func (ch *Checker) reqAnnotationLevel() string {
 	return "failure"
 }
 
-func (ch *Checker) summary(checks []*reviewdog.FilteredCheck) string {
+func (ch *Checker) summary(checks []*filter.FilteredDiagnostic) string {
 	var lines []string
 	lines = append(lines, "reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:")
 
-	var findings []*reviewdog.FilteredCheck
-	var filteredFindings []*reviewdog.FilteredCheck
+	var findings []*filter.FilteredDiagnostic
+	var filteredFindings []*filter.FilteredDiagnostic
 	for _, c := range checks {
 		if c.ShouldReport {
 			findings = append(findings, c)
@@ -214,7 +213,7 @@ func (ch *Checker) summary(checks []*reviewdog.FilteredCheck) string {
 	return strings.Join(lines, "\n")
 }
 
-func (ch *Checker) summaryFindings(name string, checks []*reviewdog.FilteredCheck) []string {
+func (ch *Checker) summaryFindings(name string, checks []*filter.FilteredDiagnostic) []string {
 	var lines []string
 	lines = append(lines, "<details>")
 	lines = append(lines, fmt.Sprintf("<summary>%s (%d)</summary>", name, len(checks)))
@@ -231,7 +230,7 @@ func (ch *Checker) summaryFindings(name string, checks []*reviewdog.FilteredChec
 	return lines
 }
 
-func (ch *Checker) toCheckRunAnnotation(c *reviewdog.FilteredCheck) *github.CheckRunAnnotation {
+func (ch *Checker) toCheckRunAnnotation(c *filter.FilteredDiagnostic) *github.CheckRunAnnotation {
 	loc := c.Diagnostic.GetLocation()
 	startLine := int(loc.GetRange().GetStart().GetLine())
 	endLine := int(loc.GetRange().GetEnd().GetLine())
diff --git a/doghouse/service.go b/doghouse/service.go
index 97e18ba4..fd61029b 100644
--- a/doghouse/service.go
+++ b/doghouse/service.go
@@ -1,8 +1,7 @@
 package doghouse
 
 import (
-	"github.com/reviewdog/reviewdog"
-	"github.com/reviewdog/reviewdog/difffilter"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
 
@@ -38,7 +37,7 @@ type CheckRequest struct {
 	// Optional.
 	Level string `json:"level"`
 
-	// Deprecated: Use FilterMode == difffilter.NoFilter instead.
+	// Deprecated: Use FilterMode == filter.NoFilter instead.
 	//
 	// OutsideDiff represents whether it report results in outside diff or not as
 	// annotations. It's useful only when PullRequest != 0. If PullRequest is
@@ -49,7 +48,7 @@ type CheckRequest struct {
 
 	// FilterMode represents a way to filter checks results
 	// Optional.
-	FilterMode difffilter.Mode `json:"filter_mode"`
+	FilterMode filter.Mode `json:"filter_mode"`
 }
 
 // CheckResponse represents doghouse GitHub check response.
@@ -66,7 +65,7 @@ type CheckResponse struct {
 	// TODO(haya14busa): Consider to move this type to this package to avoid
 	// (cyclic) import.
 	// Optional.
-	CheckedResults []*reviewdog.FilteredCheck `json:"checked_results"`
+	CheckedResults []*filter.FilteredDiagnostic `json:"checked_results"`
 
 	// Conclusion of check result, which is same as GitHub's conclusion of Check
 	// API. https://developer.github.com/v3/checks/runs/#parameters-1
diff --git a/difffilter/filter.go b/filter/diff_filter.go
similarity index 89%
rename from difffilter/filter.go
rename to filter/diff_filter.go
index e33cc4bf..43af4fbe 100644
--- a/difffilter/filter.go
+++ b/filter/diff_filter.go
@@ -1,4 +1,4 @@
-package difffilter
+package filter
 
 import (
 	"fmt"
@@ -86,8 +86,8 @@ type difflines map[normalizedPath]map[int]*diff.Line
 // difffiles is a hash table of normalizedPath to *diff.FileDiff.
 type difffiles map[normalizedPath]*diff.FileDiff
 
-// New creates a new DiffFilter.
-func New(diff []*diff.FileDiff, strip int, cwd string, mode Mode) *DiffFilter {
+// NewDiffFilter creates a new DiffFilter.
+func NewDiffFilter(diff []*diff.FileDiff, strip int, cwd string, mode Mode) *DiffFilter {
 	df := &DiffFilter{
 		strip:     strip,
 		cwd:       cwd,
@@ -153,19 +153,7 @@ func (df *DiffFilter) isSignificantLine(line *diff.Line) bool {
 type normalizedPath struct{ p string }
 
 func (df *DiffFilter) normalizePath(path string) normalizedPath {
-	path = filepath.Clean(path)
-	// Convert absolute path to relative path only if the path is in current
-	// directory.
-	if filepath.IsAbs(path) && df.cwd != "" && contains(path, df.cwd) {
-		relPath, err := filepath.Rel(df.cwd, path)
-		if err == nil {
-			path = relPath
-		}
-	}
-	if !filepath.IsAbs(path) && df.projectRelPath != "" {
-		path = filepath.Join(df.projectRelPath, path)
-	}
-	return normalizedPath{p: filepath.ToSlash(path)}
+	return normalizedPath{p: NormalizePath(path, df.cwd, df.projectRelPath)}
 }
 
 func contains(path, base string) bool {
diff --git a/filter.go b/filter/filter.go
similarity index 63%
rename from filter.go
rename to filter/filter.go
index aa4b3d45..848faa31 100644
--- a/filter.go
+++ b/filter/filter.go
@@ -1,15 +1,14 @@
-package reviewdog
+package filter
 
 import (
 	"path/filepath"
 
 	"github.com/reviewdog/reviewdog/diff"
-	"github.com/reviewdog/reviewdog/difffilter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
 
-// FilteredCheck represents Diagnostic with filtering info.
-type FilteredCheck struct {
+// FilteredDiagnostic represents Diagnostic with filtering info.
+type FilteredDiagnostic struct {
 	Diagnostic   *rdf.Diagnostic
 	ShouldReport bool
 	// false if the result is outside diff files.
@@ -23,14 +22,15 @@ type FilteredCheck struct {
 }
 
 // FilterCheck filters check results by diff. It doesn't drop check which
-// is not in diff but set FilteredCheck.ShouldReport field false.
+// is not in diff but set FilteredDiagnostic.ShouldReport field false.
 func FilterCheck(results []*rdf.Diagnostic, diff []*diff.FileDiff, strip int,
-	cwd string, mode difffilter.Mode) []*FilteredCheck {
-	checks := make([]*FilteredCheck, 0, len(results))
-	df := difffilter.New(diff, strip, cwd, mode)
+	cwd string, mode Mode) []*FilteredDiagnostic {
+	checks := make([]*FilteredDiagnostic, 0, len(results))
+	df := NewDiffFilter(diff, strip, cwd, mode)
 	for _, result := range results {
-		check := &FilteredCheck{Diagnostic: result}
+		check := &FilteredDiagnostic{Diagnostic: result}
 		loc := result.GetLocation()
+		loc.Path = NormalizePath(loc.GetPath(), cwd, "")
 		startLine := int(loc.GetRange().GetStart().GetLine())
 		endLine := int(loc.GetRange().GetEnd().GetLine())
 		if endLine == 0 {
@@ -50,40 +50,41 @@ func FilterCheck(results []*rdf.Diagnostic, diff []*diff.FileDiff, strip int,
 				}
 			}
 		}
-		loc.Path = CleanPath(loc.GetPath(), cwd)
+		// loc.Path = NormalizePath(loc.GetPath(), cwd, "")
 		checks = append(checks, check)
 	}
 	return checks
 }
 
-// CleanPath clean up given path. If workdir is not empty, it returns relative
-// path to the given workdir.
-//
-// TODO(haya14busa): DRY. Create shared logic between this and
-// difffilter.normalizePath.
-func CleanPath(path, workdir string) string {
-	p := path
-	if filepath.IsAbs(path) && workdir != "" {
+// NormalizePath return normalized path with workdir and relative path to
+// project.
+func NormalizePath(path, workdir, projectRelPath string) string {
+	path = filepath.Clean(path)
+	if path == "." {
+		return ""
+	}
+	// Convert absolute path to relative path only if the path is in current
+	// directory.
+	if filepath.IsAbs(path) && workdir != "" && contains(path, workdir) {
 		relPath, err := filepath.Rel(workdir, path)
 		if err == nil {
-			p = relPath
+			path = relPath
 		}
 	}
-	p = filepath.Clean(p)
-	if p == "." {
-		return ""
+	if !filepath.IsAbs(path) && projectRelPath != "" {
+		path = filepath.Join(projectRelPath, path)
 	}
-	return filepath.ToSlash(p)
+	return filepath.ToSlash(path)
 }
 
 func getOldPosition(filediff *diff.FileDiff, strip int, newPath string, newLine int) (oldPath string, oldLine int) {
 	if filediff == nil {
 		return "", 0
 	}
-	if difffilter.NormalizeDiffPath(filediff.PathNew, strip) != newPath {
+	if NormalizeDiffPath(filediff.PathNew, strip) != newPath {
 		return "", 0
 	}
-	oldPath = difffilter.NormalizeDiffPath(filediff.PathOld, strip)
+	oldPath = NormalizeDiffPath(filediff.PathOld, strip)
 	delta := 0
 	for _, hunk := range filediff.Hunks {
 		if newLine < hunk.StartLineNew {
diff --git a/project/run.go b/project/run.go
index 90a6128d..d52f03cf 100644
--- a/project/run.go
+++ b/project/run.go
@@ -14,7 +14,7 @@ import (
 
 	"github.com/reviewdog/reviewdog"
 	"github.com/reviewdog/reviewdog/diff"
-	"github.com/reviewdog/reviewdog/difffilter"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/parser"
 )
 
@@ -91,7 +91,7 @@ func RunAndParse(ctx context.Context, conf *Config, runners map[string]bool, def
 }
 
 // Run runs reviewdog tasks based on Config.
-func Run(ctx context.Context, conf *Config, runners map[string]bool, c reviewdog.CommentService, d reviewdog.DiffService, teeMode bool, filterMode difffilter.Mode, failOnError bool) error {
+func Run(ctx context.Context, conf *Config, runners map[string]bool, c reviewdog.CommentService, d reviewdog.DiffService, teeMode bool, filterMode filter.Mode, failOnError bool) error {
 	results, err := RunAndParse(ctx, conf, runners, "", teeMode) // Level is not used.
 	if err != nil {
 		return err
diff --git a/proto/rdf/reviewdog.pb.go b/proto/rdf/reviewdog.pb.go
index 3a59ed11..b8fbcf25 100644
--- a/proto/rdf/reviewdog.pb.go
+++ b/proto/rdf/reviewdog.pb.go
@@ -21,11 +21,12 @@
 package rdf
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
diff --git a/resultmap.go b/resultmap.go
index 588b2e32..785dca72 100644
--- a/resultmap.go
+++ b/resultmap.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"sync"
 
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
 
@@ -75,7 +76,7 @@ func (rm *ResultMap) Len() int {
 
 type FilteredResult struct {
 	Level         string
-	FilteredCheck []*FilteredCheck
+	FilteredDiagnostic []*filter.FilteredDiagnostic
 }
 
 // FilteredResultMap represents a concurrent-safe map to store Diagnostics generated by concurrent jobs.
diff --git a/reviewdog.go b/reviewdog.go
index 96a232e1..39170aa2 100644
--- a/reviewdog.go
+++ b/reviewdog.go
@@ -8,7 +8,7 @@ import (
 	"os"
 
 	"github.com/reviewdog/reviewdog/diff"
-	"github.com/reviewdog/reviewdog/difffilter"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/parser"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
@@ -21,24 +21,24 @@ type Reviewdog struct {
 	p           parser.Parser
 	c           CommentService
 	d           DiffService
-	filterMode  difffilter.Mode
+	filterMode  filter.Mode
 	failOnError bool
 }
 
 // NewReviewdog returns a new Reviewdog.
-func NewReviewdog(toolname string, p parser.Parser, c CommentService, d DiffService, filterMode difffilter.Mode, failOnError bool) *Reviewdog {
+func NewReviewdog(toolname string, p parser.Parser, c CommentService, d DiffService, filterMode filter.Mode, failOnError bool) *Reviewdog {
 	return &Reviewdog{p: p, c: c, d: d, toolname: toolname, filterMode: filterMode, failOnError: failOnError}
 }
 
 // RunFromResult creates a new Reviewdog and runs it with check results.
 func RunFromResult(ctx context.Context, c CommentService, results []*rdf.Diagnostic,
-	filediffs []*diff.FileDiff, strip int, toolname string, filterMode difffilter.Mode, failOnError bool) error {
+	filediffs []*diff.FileDiff, strip int, toolname string, filterMode filter.Mode, failOnError bool) error {
 	return (&Reviewdog{c: c, toolname: toolname, filterMode: filterMode, failOnError: failOnError}).runFromResult(ctx, results, filediffs, strip, failOnError)
 }
 
 // Comment represents a reported result as a comment.
 type Comment struct {
-	Result   *FilteredCheck
+	Result   *filter.FilteredDiagnostic
 	ToolName string
 	Body     string
 }
@@ -68,7 +68,7 @@ func (w *Reviewdog) runFromResult(ctx context.Context, results []*rdf.Diagnostic
 		return err
 	}
 
-	checks := FilterCheck(results, filediffs, strip, wd, w.filterMode)
+	checks := filter.FilterCheck(results, filediffs, strip, wd, w.filterMode)
 	hasViolations := false
 
 	for _, check := range checks {
@@ -118,4 +118,3 @@ func (w *Reviewdog) Run(ctx context.Context, r io.Reader) error {
 
 	return w.runFromResult(ctx, results, filediffs, w.d.Strip(), w.failOnError)
 }
-


Test patch:
diff --git a/cmd/reviewdog/doghouse_test.go b/cmd/reviewdog/doghouse_test.go
index 91bde139..8aa6fac0 100644
--- a/cmd/reviewdog/doghouse_test.go
+++ b/cmd/reviewdog/doghouse_test.go
@@ -16,9 +16,9 @@ import (
 
 	"github.com/reviewdog/reviewdog"
 	"github.com/reviewdog/reviewdog/cienv"
-	"github.com/reviewdog/reviewdog/difffilter"
 	"github.com/reviewdog/reviewdog/doghouse"
 	"github.com/reviewdog/reviewdog/doghouse/client"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/project"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
@@ -313,7 +313,7 @@ func TestPostResultSet_withReportURL(t *testing.T) {
 		SHA:         sha,
 	}
 
-	opt := &option{filterMode: difffilter.ModeAdded}
+	opt := &option{filterMode: filter.ModeAdded}
 	if _, err := postResultSet(context.Background(), &resultSet, ghInfo, fakeCli, opt); err != nil {
 		t.Fatal(err)
 	}
@@ -327,7 +327,7 @@ func TestPostResultSet_withoutReportURL(t *testing.T) {
 		sha   = "1414"
 	)
 
-	wantResults := []*reviewdog.FilteredCheck{{ShouldReport: true}}
+	wantResults := []*filter.FilteredDiagnostic{{ShouldReport: true}}
 	fakeCli := &fakeDoghouseServerCli{}
 	fakeCli.FakeCheck = func(ctx context.Context, req *doghouse.CheckRequest) (*doghouse.CheckResponse, error) {
 		return &doghouse.CheckResponse{CheckedResults: wantResults}, nil
@@ -338,7 +338,7 @@ func TestPostResultSet_withoutReportURL(t *testing.T) {
 
 	ghInfo := &cienv.BuildInfo{Owner: owner, Repo: repo, PullRequest: prNum, SHA: sha}
 
-	opt := &option{filterMode: difffilter.ModeAdded}
+	opt := &option{filterMode: filter.ModeAdded}
 	resp, err := postResultSet(context.Background(), &resultSet, ghInfo, fakeCli, opt)
 	if err != nil {
 		t.Fatal(err)
@@ -350,7 +350,7 @@ func TestPostResultSet_withoutReportURL(t *testing.T) {
 	if err != nil {
 		t.Fatalf("should have result for name1: %v", err)
 	}
-	if diff := cmp.Diff(results.FilteredCheck, wantResults, protocmp.Transform()); diff != "" {
+	if diff := cmp.Diff(results.FilteredDiagnostic, wantResults, protocmp.Transform()); diff != "" {
 		t.Errorf("results has diff:\n%s", diff)
 	}
 }
@@ -385,7 +385,7 @@ func TestPostResultSet_conclusion(t *testing.T) {
 		fakeCli.FakeCheck = func(ctx context.Context, req *doghouse.CheckRequest) (*doghouse.CheckResponse, error) {
 			return &doghouse.CheckResponse{ReportURL: "xxx", Conclusion: tt.conclusion}, nil
 		}
-		opt := &option{filterMode: difffilter.ModeAdded, failOnError: tt.failOnError}
+		opt := &option{filterMode: filter.ModeAdded, failOnError: tt.failOnError}
 		id := fmt.Sprintf("[conclusion=%s, failOnError=%v]", tt.conclusion, tt.failOnError)
 		_, err := postResultSet(context.Background(), &resultSet, ghInfo, fakeCli, opt)
 		if tt.wantErr && err == nil {
@@ -414,7 +414,7 @@ func TestPostResultSet_withEmptyResponse(t *testing.T) {
 
 	ghInfo := &cienv.BuildInfo{Owner: owner, Repo: repo, PullRequest: prNum, SHA: sha}
 
-	opt := &option{filterMode: difffilter.ModeAdded}
+	opt := &option{filterMode: filter.ModeAdded}
 	if _, err := postResultSet(context.Background(), &resultSet, ghInfo, fakeCli, opt); err == nil {
 		t.Error("got no error but want report missing error")
 	}
@@ -428,7 +428,7 @@ func TestReportResults(t *testing.T) {
 	defer cleanup()
 	filteredResultSet := new(reviewdog.FilteredResultMap)
 	filteredResultSet.Store("name1", &reviewdog.FilteredResult{
-		FilteredCheck: []*reviewdog.FilteredCheck{
+		FilteredDiagnostic: []*filter.FilteredDiagnostic{
 			{
 				Diagnostic: &rdf.Diagnostic{
 					OriginalOutput: "name1-L1\nname1-L2",
@@ -444,7 +444,7 @@ func TestReportResults(t *testing.T) {
 		},
 	})
 	filteredResultSet.Store("name2", &reviewdog.FilteredResult{
-		FilteredCheck: []*reviewdog.FilteredCheck{
+		FilteredDiagnostic: []*filter.FilteredDiagnostic{
 			{
 				Diagnostic: &rdf.Diagnostic{
 					OriginalOutput: "name1-L1\nname1-L2",
@@ -477,7 +477,7 @@ func TestReportResults_inGitHubAction(t *testing.T) {
 	defer cleanup()
 	filteredResultSet := new(reviewdog.FilteredResultMap)
 	filteredResultSet.Store("name1", &reviewdog.FilteredResult{
-		FilteredCheck: []*reviewdog.FilteredCheck{
+		FilteredDiagnostic: []*filter.FilteredDiagnostic{
 			{
 				Diagnostic: &rdf.Diagnostic{
 					OriginalOutput: "name1-L1\nname1-L2",
@@ -503,7 +503,7 @@ func TestReportResults_noResultsShouldReport(t *testing.T) {
 	defer cleanup()
 	filteredResultSet := new(reviewdog.FilteredResultMap)
 	filteredResultSet.Store("name1", &reviewdog.FilteredResult{
-		FilteredCheck: []*reviewdog.FilteredCheck{
+		FilteredDiagnostic: []*filter.FilteredDiagnostic{
 			{
 				Diagnostic: &rdf.Diagnostic{
 					OriginalOutput: "name1-L1\nname1-L2",
@@ -519,7 +519,7 @@ func TestReportResults_noResultsShouldReport(t *testing.T) {
 		},
 	})
 	filteredResultSet.Store("name2", &reviewdog.FilteredResult{
-		FilteredCheck: []*reviewdog.FilteredCheck{
+		FilteredDiagnostic: []*filter.FilteredDiagnostic{
 			{
 				Diagnostic: &rdf.Diagnostic{
 					OriginalOutput: "name1-L1\nname1-L2",
diff --git a/cmd/reviewdog/main_test.go b/cmd/reviewdog/main_test.go
index 70326194..330d574d 100644
--- a/cmd/reviewdog/main_test.go
+++ b/cmd/reviewdog/main_test.go
@@ -10,7 +10,7 @@ import (
 	"testing"
 
 	"github.com/reviewdog/reviewdog/commands"
-	"github.com/reviewdog/reviewdog/difffilter"
+	"github.com/reviewdog/reviewdog/filter"
 )
 
 func TestRun_local(t *testing.T) {
@@ -95,7 +95,7 @@ func TestRun_local_nofilter(t *testing.T) {
 		t.Errorf("got no error, but want error")
 	}
 
-	opt.filterMode = difffilter.ModeNoFilter
+	opt.filterMode = filter.ModeNoFilter
 	if err := run(strings.NewReader(stdin), stdout, opt); err != nil {
 		t.Error(err)
 	}
diff --git a/comment_iowriter_test.go b/comment_iowriter_test.go
index 2105c3ab..8b6a3047 100644
--- a/comment_iowriter_test.go
+++ b/comment_iowriter_test.go
@@ -6,6 +6,7 @@ import (
 	"strings"
 	"testing"
 
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
 
@@ -16,7 +17,7 @@ func TestUnifiedCommentWriter_Post(t *testing.T) {
 	}{
 		{
 			in: &Comment{
-				Result: &FilteredCheck{
+				Result: &filter.FilteredDiagnostic{
 					Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{Path: "/path/to/file"}},
 				},
 				ToolName: "tool name",
@@ -26,7 +27,7 @@ func TestUnifiedCommentWriter_Post(t *testing.T) {
 		},
 		{
 			in: &Comment{
-				Result: &FilteredCheck{
+				Result: &filter.FilteredDiagnostic{
 					Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{
 						Path: "/path/to/file",
 						Range: &rdf.Range{Start: &rdf.Position{
@@ -41,7 +42,7 @@ func TestUnifiedCommentWriter_Post(t *testing.T) {
 		},
 		{
 			in: &Comment{
-				Result: &FilteredCheck{
+				Result: &filter.FilteredDiagnostic{
 					Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{
 						Path: "/path/to/file",
 						Range: &rdf.Range{Start: &rdf.Position{
@@ -56,7 +57,7 @@ func TestUnifiedCommentWriter_Post(t *testing.T) {
 		},
 		{
 			in: &Comment{
-				Result: &FilteredCheck{
+				Result: &filter.FilteredDiagnostic{
 					Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{
 						Path: "/path/to/file",
 						Range: &rdf.Range{Start: &rdf.Position{
diff --git a/comment_test.go b/comment_test.go
index d9e64216..b16547f5 100644
--- a/comment_test.go
+++ b/comment_test.go
@@ -6,6 +6,7 @@ import (
 	"strings"
 	"testing"
 
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
 
@@ -16,7 +17,7 @@ func TestMultiCommentService_Post(t *testing.T) {
 
 	const want = "line1\nline2"
 
-	c := &Comment{Result: &FilteredCheck{Diagnostic: &rdf.Diagnostic{OriginalOutput: want}}}
+	c := &Comment{Result: &filter.FilteredDiagnostic{Diagnostic: &rdf.Diagnostic{OriginalOutput: want}}}
 	if err := w.Post(context.Background(), c); err != nil {
 		t.Fatal(err)
 	}
diff --git a/doghouse/server/doghouse_test.go b/doghouse/server/doghouse_test.go
index bd919804..e41db45d 100644
--- a/doghouse/server/doghouse_test.go
+++ b/doghouse/server/doghouse_test.go
@@ -9,8 +9,8 @@ import (
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-github/v32/github"
 
-	"github.com/reviewdog/reviewdog/difffilter"
 	"github.com/reviewdog/reviewdog/doghouse"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
 
@@ -274,7 +274,7 @@ func TestCheck_OK(t *testing.T) {
 	}
 }
 
-func testOutsideDiff(t *testing.T, outsideDiff bool, filterMode difffilter.Mode) {
+func testOutsideDiff(t *testing.T, outsideDiff bool, filterMode filter.Mode) {
 	const (
 		name        = "haya14busa-linter"
 		owner       = "haya14busa"
@@ -371,10 +371,10 @@ func testOutsideDiff(t *testing.T, outsideDiff bool, filterMode difffilter.Mode)
 
 func TestCheck_OK_deprecated_outsidediff(t *testing.T) {
 	t.Run("deprecated: outside_diff", func(t *testing.T) {
-		testOutsideDiff(t, true, difffilter.ModeDefault)
+		testOutsideDiff(t, true, filter.ModeDefault)
 	})
 	t.Run("filter-mode=NoFilter", func(t *testing.T) {
-		testOutsideDiff(t, false, difffilter.ModeNoFilter)
+		testOutsideDiff(t, false, filter.ModeNoFilter)
 	})
 }
 
diff --git a/difffilter/filter_test.go b/filter/diff_filter_test.go
similarity index 95%
rename from difffilter/filter_test.go
rename to filter/diff_filter_test.go
index 5a7840dd..ea04860c 100644
--- a/difffilter/filter_test.go
+++ b/filter/diff_filter_test.go
@@ -1,4 +1,4 @@
-package difffilter
+package filter
 
 import (
 	"os"
@@ -58,8 +58,8 @@ const sampleDiffRoot = `--- a/sample.old.txt	2016-10-13 05:09:35.820791185 +0900
 \ No newline at end of file
 `
 
-const sampleDiffSubDir = `--- a/difffilter/sample.old.txt	2016-10-13 05:09:35.820791185 +0900
-+++ b/difffilter/sample.new.txt	2016-10-13 05:15:26.839245048 +0900
+const sampleDiffSubDir = `--- a/filter/sample.old.txt	2016-10-13 05:09:35.820791185 +0900
++++ b/filter/sample.new.txt	2016-10-13 05:15:26.839245048 +0900
 @@ -1,3 +1,4 @@
  unchanged, contextual line
 -deleted line
@@ -210,7 +210,7 @@ func TestDiffFilter_root(t *testing.T) {
 		},
 	}
 	for _, tt := range tests {
-		df := New(files, 1, getCwd(), tt.mode)
+		df := NewDiffFilter(files, 1, getCwd(), tt.mode)
 		if got, gotFile, gotLine := df.ShouldReport(tt.path, tt.lnum); got != tt.want ||
 			(gotFile != nil) != tt.wantFileDiff ||
 			(gotLine != nil) != tt.wantLineDiff {
@@ -267,7 +267,7 @@ func TestDiffFilter_subdir(t *testing.T) {
 		},
 	}
 	for _, tt := range tests {
-		df := New(files, 1, getCwd(), tt.mode)
+		df := NewDiffFilter(files, 1, getCwd(), tt.mode)
 		if got, gotFile, gotLine := df.ShouldReport(tt.path, tt.lnum); got != tt.want ||
 			(gotFile != nil) != tt.wantFileDiff ||
 			(gotLine != nil) != tt.wantLineDiff {
diff --git a/filter_test.go b/filter/filter_test.go
similarity index 95%
rename from filter_test.go
rename to filter/filter_test.go
index 8c01c73b..9113e8f4 100644
--- a/filter_test.go
+++ b/filter/filter_test.go
@@ -1,4 +1,4 @@
-package reviewdog
+package filter
 
 import (
 	"strings"
@@ -8,7 +8,6 @@ import (
 	"google.golang.org/protobuf/testing/protocmp"
 
 	"github.com/reviewdog/reviewdog/diff"
-	"github.com/reviewdog/reviewdog/difffilter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 )
 
@@ -81,7 +80,7 @@ func TestFilterCheckByAddedLines(t *testing.T) {
 			},
 		},
 	}
-	want := []*FilteredCheck{
+	want := []*FilteredDiagnostic{
 		{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
@@ -153,7 +152,7 @@ func TestFilterCheckByAddedLines(t *testing.T) {
 		},
 	}
 	filediffs, _ := diff.ParseMultiFile(strings.NewReader(diffContent))
-	got := FilterCheck(results, filediffs, 0, "", difffilter.ModeAdded)
+	got := FilterCheck(results, filediffs, 0, "", ModeAdded)
 	if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" {
 		t.Error(diff)
 	}
@@ -181,7 +180,7 @@ func TestFilterCheckByDiffContext(t *testing.T) {
 			},
 		},
 	}
-	want := []*FilteredCheck{
+	want := []*FilteredDiagnostic{
 		{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
@@ -223,7 +222,7 @@ func TestFilterCheckByDiffContext(t *testing.T) {
 		},
 	}
 	filediffs, _ := diff.ParseMultiFile(strings.NewReader(diffContent))
-	got := FilterCheck(results, filediffs, 0, "", difffilter.ModeDiffContext)
+	got := FilterCheck(results, filediffs, 0, "", ModeDiffContext)
 	if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" {
 		t.Error(diff)
 	}
@@ -231,7 +230,7 @@ func TestFilterCheckByDiffContext(t *testing.T) {
 
 func findFileDiff(filediffs []*diff.FileDiff, path string, strip int) *diff.FileDiff {
 	for _, file := range filediffs {
-		if difffilter.NormalizeDiffPath(file.PathNew, strip) == path {
+		if NormalizeDiffPath(file.PathNew, strip) == path {
 			return file
 		}
 	}
diff --git a/project/run_test.go b/project/run_test.go
index ea4342e5..e03fb3eb 100644
--- a/project/run_test.go
+++ b/project/run_test.go
@@ -9,7 +9,7 @@ import (
 	"testing"
 
 	"github.com/reviewdog/reviewdog"
-	"github.com/reviewdog/reviewdog/difffilter"
+	"github.com/reviewdog/reviewdog/filter"
 )
 
 type fakeDiffService struct {
@@ -39,7 +39,7 @@ func TestRun(t *testing.T) {
 
 	t.Run("empty", func(t *testing.T) {
 		conf := &Config{}
-		if err := Run(ctx, conf, nil, nil, nil, false, difffilter.ModeAdded, false); err != nil {
+		if err := Run(ctx, conf, nil, nil, nil, false, filter.ModeAdded, false); err != nil {
 			t.Error(err)
 		}
 	})
@@ -50,7 +50,7 @@ func TestRun(t *testing.T) {
 				"test": {},
 			},
 		}
-		if err := Run(ctx, conf, nil, nil, nil, false, difffilter.ModeAdded, false); err == nil {
+		if err := Run(ctx, conf, nil, nil, nil, false, filter.ModeAdded, false); err == nil {
 			t.Error("want error, got nil")
 		} else {
 			t.Log(err)
@@ -71,7 +71,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, nil, nil, ds, false, difffilter.ModeAdded, false); err == nil {
+		if err := Run(ctx, conf, nil, nil, ds, false, filter.ModeAdded, false); err == nil {
 			t.Error("want error, got nil")
 		} else {
 			t.Log(err)
@@ -99,7 +99,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, nil, cs, ds, false, difffilter.ModeAdded, false); err != nil {
+		if err := Run(ctx, conf, nil, cs, ds, false, filter.ModeAdded, false); err != nil {
 			t.Error(err)
 		}
 		want := ""
@@ -129,7 +129,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, nil, cs, ds, false, difffilter.ModeAdded, false); err == nil {
+		if err := Run(ctx, conf, nil, cs, ds, false, filter.ModeAdded, false); err == nil {
 			t.Error("want error, got nil")
 		} else {
 			t.Log(err)
@@ -157,7 +157,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, nil, cs, ds, true, difffilter.ModeAdded, false); err == nil {
+		if err := Run(ctx, conf, nil, cs, ds, true, filter.ModeAdded, false); err == nil {
 			t.Error("want error, got nil")
 		} else {
 			t.Log(err)
@@ -187,7 +187,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, nil, cs, ds, false, difffilter.ModeAdded, false); err != nil {
+		if err := Run(ctx, conf, nil, cs, ds, false, filter.ModeAdded, false); err != nil {
 			t.Error(err)
 		}
 	})
@@ -213,7 +213,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, nil, cs, ds, true, difffilter.ModeAdded, false); err != nil {
+		if err := Run(ctx, conf, nil, cs, ds, true, filter.ModeAdded, false); err != nil {
 			t.Error(err)
 		}
 		want := "hi\n"
@@ -249,7 +249,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, map[string]bool{"test2": true}, cs, ds, false, difffilter.ModeAdded, false); err != nil {
+		if err := Run(ctx, conf, map[string]bool{"test2": true}, cs, ds, false, filter.ModeAdded, false); err != nil {
 			t.Error(err)
 		}
 		if called != 1 {
@@ -282,7 +282,7 @@ func TestRun(t *testing.T) {
 				},
 			},
 		}
-		if err := Run(ctx, conf, map[string]bool{"hoge": true}, cs, ds, false, difffilter.ModeAdded, false); err == nil {
+		if err := Run(ctx, conf, map[string]bool{"hoge": true}, cs, ds, false, filter.ModeAdded, false); err == nil {
 			t.Error("got no error but want runner not found error")
 		}
 	})
diff --git a/reviewdog_test.go b/reviewdog_test.go
index f53f7f86..127d1136 100644
--- a/reviewdog_test.go
+++ b/reviewdog_test.go
@@ -7,7 +7,7 @@ import (
 	"testing"
 
 	"github.com/reviewdog/errorformat"
-	"github.com/reviewdog/reviewdog/difffilter"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/parser"
 )
 
@@ -49,7 +49,7 @@ golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..
 	p := parser.NewErrorformatParser(efm)
 	c := NewRawCommentWriter(os.Stdout)
 	d := NewDiffString(difftext, 1)
-	app := NewReviewdog("tool name", p, c, d, difffilter.ModeAdded, false)
+	app := NewReviewdog("tool name", p, c, d, filter.ModeAdded, false)
 	app.Run(context.Background(), strings.NewReader(lintresult))
 	// Unordered output:
 	// golint.new.go:5:5: exported var NewError1 should have comment or be unexported
@@ -95,7 +95,7 @@ index 34cacb9..a727dd3 100644
 	efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`})
 	p := parser.NewErrorformatParser(efm)
 	d := NewDiffString(difftext, 1)
-	app := NewReviewdog("tool name", p, c, d, difffilter.ModeAdded, false)
+	app := NewReviewdog("tool name", p, c, d, filter.ModeAdded, false)
 	app.Run(context.Background(), strings.NewReader(lintresult))
 }
 
@@ -128,7 +128,7 @@ golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..
 	efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`})
 	p := parser.NewErrorformatParser(efm)
 	d := NewDiffString(difftext, 1)
-	app := NewReviewdog("tool name", p, c, d, difffilter.ModeAdded, false)
+	app := NewReviewdog("tool name", p, c, d, filter.ModeAdded, false)
 	err := app.Run(context.Background(), strings.NewReader(lintresult))
 
 	if err != nil {
@@ -164,7 +164,7 @@ golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..
 	efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`})
 	p := parser.NewErrorformatParser(efm)
 	d := NewDiffString(difftext, 1)
-	app := NewReviewdog("tool name", p, c, d, difffilter.ModeAdded, true)
+	app := NewReviewdog("tool name", p, c, d, filter.ModeAdded, true)
 	err := app.Run(context.Background(), strings.NewReader(lintresult))
 
 	if err != nil && err.Error() != "input data has violations" {
diff --git a/service/gerrit/change_review_test.go b/service/gerrit/change_review_test.go
index 6bfd8189..0fbfd0b6 100644
--- a/service/gerrit/change_review_test.go
+++ b/service/gerrit/change_review_test.go
@@ -11,6 +11,7 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/reviewdog/reviewdog"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 	"golang.org/x/build/gerrit"
 )
@@ -29,7 +30,7 @@ func TestChangeReviewCommenter_Post_Flush(t *testing.T) {
 	ctx := context.Background()
 	newLnum1 := 14
 	newComment1 := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "file.go",
@@ -44,7 +45,7 @@ func TestChangeReviewCommenter_Post_Flush(t *testing.T) {
 	}
 	newLnum2 := 15
 	newComment2 := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "file2.go",
@@ -58,7 +59,7 @@ func TestChangeReviewCommenter_Post_Flush(t *testing.T) {
 		Body: "new comment 2",
 	}
 	commentOutsideDiff := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "file3.go",
diff --git a/service/github/github_test.go b/service/github/github_test.go
index d646c3a7..911aef68 100644
--- a/service/github/github_test.go
+++ b/service/github/github_test.go
@@ -15,6 +15,7 @@ import (
 	"golang.org/x/oauth2"
 
 	"github.com/reviewdog/reviewdog"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 	"github.com/reviewdog/reviewdog/service/commentutil"
 )
@@ -71,7 +72,7 @@ func TestGitHubPullRequest_Post(t *testing.T) {
 		t.Fatal(err)
 	}
 	comment := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "watchdogs.go",
@@ -293,7 +294,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
 	}
 	comments := []*reviewdog.Comment{
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -309,7 +310,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
 			Body: "already commented",
 		},
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -325,7 +326,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
 			Body: "already commented 2",
 		},
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -341,7 +342,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
 			Body: "new comment",
 		},
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -360,7 +361,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
 			Body: "multiline existing comment",
 		},
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -381,7 +382,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
 			Body: "multiline existing comment (line-break)",
 		},
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -400,7 +401,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
 			Body: "multiline new comment",
 		},
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -465,7 +466,7 @@ func TestGitHubPullRequest_Post_toomany(t *testing.T) {
 	var comments []*reviewdog.Comment
 	for i := 0; i < 100; i++ {
 		comments = append(comments, &reviewdog.Comment{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "reviewdog.go",
@@ -511,7 +512,7 @@ func TestGitHubPullRequest_workdir(t *testing.T) {
 	}
 	ctx := context.Background()
 	want := "a/b/c"
-	g.Post(ctx, &reviewdog.Comment{Result: &reviewdog.FilteredCheck{
+	g.Post(ctx, &reviewdog.Comment{Result: &filter.FilteredDiagnostic{
 		Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{Path: want}}}})
 	if got := g.postComments[0].Result.Diagnostic.GetLocation().GetPath(); got != want {
 		t.Errorf("wd=%q path=%q, want %q", g.wd, got, want)
@@ -527,7 +528,7 @@ func TestGitHubPullRequest_workdir(t *testing.T) {
 	}
 	path := "a/b/c"
 	wantPath := "cmd/" + path
-	g.Post(ctx, &reviewdog.Comment{Result: &reviewdog.FilteredCheck{
+	g.Post(ctx, &reviewdog.Comment{Result: &filter.FilteredDiagnostic{
 		Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{Path: want}}}})
 	if got := g.postComments[0].Result.Diagnostic.GetLocation().GetPath(); got != wantPath {
 		t.Errorf("wd=%q path=%q, want %q", g.wd, got, wantPath)
diff --git a/service/gitlab/gitlab_mr_commit_test.go b/service/gitlab/gitlab_mr_commit_test.go
index 73dfff1b..8a99f02f 100644
--- a/service/gitlab/gitlab_mr_commit_test.go
+++ b/service/gitlab/gitlab_mr_commit_test.go
@@ -12,6 +12,7 @@ import (
 	"github.com/xanzy/go-gitlab"
 
 	"github.com/reviewdog/reviewdog"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 	"github.com/reviewdog/reviewdog/service/commentutil"
 )
@@ -92,7 +93,7 @@ func TestGitLabMergeRequestCommitCommenter_Post_Flush_review_api(t *testing.T) {
 	// If setting exists file path, sha is changed by last commit id.
 	comments := []*reviewdog.Comment{
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "notExistFile.go",
@@ -106,7 +107,7 @@ func TestGitLabMergeRequestCommitCommenter_Post_Flush_review_api(t *testing.T) {
 			Body: "already commented",
 		},
 		{
-			Result: &reviewdog.FilteredCheck{
+			Result: &filter.FilteredDiagnostic{
 				Diagnostic: &rdf.Diagnostic{
 					Location: &rdf.Location{
 						Path: "notExistFile.go",
@@ -147,7 +148,7 @@ func TestGitLabPullRequest_workdir(t *testing.T) {
 	}
 	ctx := context.Background()
 	want := "a/b/c"
-	g.Post(ctx, &reviewdog.Comment{Result: &reviewdog.FilteredCheck{
+	g.Post(ctx, &reviewdog.Comment{Result: &filter.FilteredDiagnostic{
 		Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{Path: want}}}})
 	if got := g.postComments[0].Result.Diagnostic.GetLocation().GetPath(); got != want {
 		t.Errorf("wd=%q path=%q, want %q", g.wd, got, want)
@@ -163,7 +164,7 @@ func TestGitLabPullRequest_workdir(t *testing.T) {
 	}
 	path := "a/b/c"
 	wantPath := "cmd/" + path
-	g.Post(ctx, &reviewdog.Comment{Result: &reviewdog.FilteredCheck{
+	g.Post(ctx, &reviewdog.Comment{Result: &filter.FilteredDiagnostic{
 		Diagnostic: &rdf.Diagnostic{Location: &rdf.Location{Path: want}}}})
 	if got := g.postComments[0].Result.Diagnostic.GetLocation().GetPath(); got != wantPath {
 		t.Errorf("wd=%q path=%q, want %q", g.wd, got, wantPath)
diff --git a/service/gitlab/gitlab_mr_discussion_test.go b/service/gitlab/gitlab_mr_discussion_test.go
index 227a7410..fb3cf080 100644
--- a/service/gitlab/gitlab_mr_discussion_test.go
+++ b/service/gitlab/gitlab_mr_discussion_test.go
@@ -13,6 +13,7 @@ import (
 	"github.com/xanzy/go-gitlab"
 
 	"github.com/reviewdog/reviewdog"
+	"github.com/reviewdog/reviewdog/filter"
 	"github.com/reviewdog/reviewdog/proto/rdf"
 	"github.com/reviewdog/reviewdog/service/commentutil"
 )
@@ -23,7 +24,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
 	os.Chdir("../..")
 
 	alreadyCommented1 := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "file.go",
@@ -37,7 +38,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
 		Body: "already commented",
 	}
 	alreadyCommented2 := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "another/file.go",
@@ -51,7 +52,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
 		Body: "already commented 2",
 	}
 	newComment1 := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "file.go",
@@ -65,7 +66,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
 		Body: "new comment",
 	}
 	newComment2 := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "file2.go",
@@ -79,7 +80,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
 		Body: "new comment 2",
 	}
 	newComment3 := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "new_file.go",
@@ -95,7 +96,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
 		Body: "new comment 3",
 	}
 	commentOutsideDiff := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "path.go",
@@ -109,7 +110,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
 		Body: "comment outside diff",
 	}
 	commentWithoutLnum := &reviewdog.Comment{
-		Result: &reviewdog.FilteredCheck{
+		Result: &filter.FilteredDiagnostic{
 			Diagnostic: &rdf.Diagnostic{
 				Location: &rdf.Location{
 					Path: "path.go",