-
Notifications
You must be signed in to change notification settings - Fork 394
Suggested changes #1752
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
base: master
Are you sure you want to change the base?
Suggested changes #1752
Changes from all commits
2a00258
f05afa1
9d6dd92
8b5f0cf
735010b
328f947
e24fe6b
8a1b92c
2a58fe8
cdd2f6f
7828c12
774d389
47b369d
824ce4a
b8ddf22
2c40d3e
3e7f14b
79f5ad2
1ab171b
143fe95
69aa469
f1f9b18
7d1d863
405902c
27f595a
d48f119
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| class SuggestChanges | ||
| static_facade :call | ||
|
|
||
| def initialize(violation) | ||
| @violation = violation | ||
| @suggestion = "" | ||
| end | ||
|
|
||
| def call | ||
| violation.messages.each do |message| | ||
gylaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| apply_suggestion(message) | ||
| break if suggestion.present? | ||
| end | ||
gylaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| messages = violation.messages.join(CommentingPolicy::COMMENT_LINE_DELIMITER) | ||
|
|
||
| if suggestion.blank? | ||
| messages | ||
| else | ||
| messages + "<br>\n```suggestion\n#{suggestion}\n```" | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| attr_reader :violation | ||
| attr_accessor :suggestion | ||
|
|
||
| def apply_suggestion(message) | ||
| case message | ||
| when /Trailing whitespace detected/ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gylaz we need to figure out a better way to generate these suggestions.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, though not sure how "smart" we want to get about these. |
||
| self.suggestion = violation.source.gsub(/(.*)\s$/, '\1') | ||
| when /A space is required after ','/ | ||
| self.suggestion = violation.source.gsub(/(,)([^ ])/, ', \2') | ||
gylaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| when /Put a comma after the last parameter of a multiline method call/ | ||
| self.suggestion = violation.source + "," | ||
| when /Missing semicolon/ | ||
| self.suggestion = violation.source + ";" | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class AddSourceToViolations < ActiveRecord::Migration[5.1] | ||
| def change | ||
| add_column :violations, :source, :string | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,9 +218,11 @@ to comment about the violations on the pull request. | |
|
|
||
| `CompleteFileReview` saves each violation, the line number, and patch position, | ||
| in the `violations` table of our Postgres database. | ||
| We do not save any of your code in Postgres. | ||
| We do store the contents of the files to review temporarily in Sidekiq, and it | ||
| gets cleared out as soon as the job is processed. | ||
| We also store single lines of code that are used to report violations and | ||
| suggested changes. The data is encrypted and encoded similar to tokens using | ||
| `ActiveSupport::MessageEncryptor`. We also store the contents of the files to | ||
| review temporarily in Redis, but that is removed as soon as the Sidekiq job is | ||
| processed. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
|
||
| To browse the portions of the codebase related to | ||
| receiving and processing pull request notifications, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.