Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reviewdog Diagnostic Format #1018

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions common/analysis/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This package contains functions and classes for analyzing text structures.

load("//bazel:flex.bzl", "genlex")
load("//common/tools:jcxxgen.bzl", "jcxxgen")

licenses(["notice"])

Expand All @@ -9,6 +10,7 @@ package(
"//verilog/CST:__subpackages__",
"//verilog/analysis:__subpackages__",
"//verilog/tools/kythe:__pkg__",
"//verilog/tools/lint:__subpackages__",
],
)

Expand Down Expand Up @@ -84,6 +86,39 @@ cc_library(
],
)

cc_library(
name = "violation_handler",
srcs = ["violation_handler.cc"],
hdrs = ["violation_handler.h"],
deps = [
":lint_rule_status",
":rdformat",
"//common/strings:diff",
"//common/util:file_util",
"//common/util:user_interaction",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@jsonhpp//:jsonhpp",
]
)

jcxxgen(
name = "rdformat",
src = "rdformat.yaml",
out = "rdformat.h",
namespace = "verible::rdformat",
)

cc_test(
name = "violation_handler_test",
srcs = ["violation_handler_test.cc"],
deps = [
":violation_handler",
":rdformat",
"@com_google_googletest//:gtest_main",
]
)

cc_test(
name = "command_file_lexer_test",
size = "small",
Expand Down
13 changes: 0 additions & 13 deletions common/analysis/lint_rule_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,6 @@ void LintStatusFormatter::FormatLintRuleStatus(std::ostream* stream,
}
}

struct LintViolationWithStatus {
const LintViolation* violation;
const LintRuleStatus* status;

LintViolationWithStatus(const LintViolation* v, const LintRuleStatus* s)
: violation(v), status(s) {}

bool operator<(const LintViolationWithStatus& r) const {
// compares addresses which correspond to locations within the same string
return violation->token.text().data() < r.violation->token.text().data();
}
};

void LintStatusFormatter::FormatLintRuleStatuses(
std::ostream* stream, const std::vector<LintRuleStatus>& statuses,
absl::string_view base, absl::string_view path,
Expand Down
13 changes: 13 additions & 0 deletions common/analysis/lint_rule_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ struct LintRuleStatus {
std::set<LintViolation> violations;
};

struct LintViolationWithStatus {
const LintViolation* violation;
const LintRuleStatus* status;

LintViolationWithStatus(const LintViolation* v, const LintRuleStatus* s)
: violation(v), status(s) {}

bool operator<(const LintViolationWithStatus& r) const {
// compares addresses which correspond to locations within the same string
return violation->token.text().data() < r.violation->token.text().data();
}
};

// LintStatusFormatter is a class for printing LintRuleStatus's and
// LintViolations to an output stream
// Usage:
Expand Down
37 changes: 37 additions & 0 deletions common/analysis/rdformat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Position:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget copyright header and probalby a link to the spec we try to implement here
( https://github.com/reviewdog/reviewdog/tree/master/proto/rdf )

line?: integer
column?: integer

Range:
start: Position
end?: Position

Location:
path: string
range?: Range

Source:
name: string
url?: string

Code:
value: string
url?: string

Suggestion:
range: Range
text: string

Diagnostic:
message: string
location: Location
severity?: string # TODO this is an enum
source?: Source
code?: Code
suggestions+?: Suggestion
original_output?: string

DiagnosticResult:
diagnostics+: Diagnostic
source?: Source
severity?: string # TODO this is an enum
Loading