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

Update codeclimate formatter to never show source #14

Closed
wants to merge 5 commits into from
Closed
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
24 changes: 15 additions & 9 deletions src/flake8_json_reporter/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,33 @@ def _write(self, output):
if self.output_fd is None or self.options.tee:
print(output, end=self.newline)

def write_line(self, line):
def write(self, line=None, source=None) -> None:
"""Override write for convenience."""
self.write(line, None)
self._write(line)

def start(self):
"""Override the default to start printing JSON."""
super().start()
self.write_line("{")
self.write("{")
self.files_reported_count = 0

def stop(self):
"""Override the default to finish printing JSON."""
self.write_line("}")
self.write("}")

def beginning(self, filename):
"""We're starting a new file."""
json_filename = json.dumps(filename)
if self.files_reported_count > 0:
self.write_line(f", {json_filename}: [")
self.write(f", {json_filename}: [")
else:
self.write_line(f"{json_filename}: [")
self.write(f"{json_filename}: [")
self.reported_errors_count = 0

def finished(self, filename):
"""We've finished processing a file."""
self.files_reported_count += 1
self.write_line("]")
self.write("]")

@staticmethod
def _fingerprint(violation):
Expand Down Expand Up @@ -151,7 +151,13 @@ def format(self, violation):
"""Format a violation."""
formatted = json.dumps(self.dictionary_from(violation))
if self.reported_errors_count > 0:
self.write_line(f", {formatted}")
string = f", {formatted}"
else:
self.write_line(formatted)
string = formatted

self.reported_errors_count += 1
return string

def show_source(self, violation):
"""Codeclimate does not have a good place to show the source."""
return None