-
Notifications
You must be signed in to change notification settings - Fork 47
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
Updating Toolkit To Start Using Cargo Fmt #524
Conversation
7f238c5
to
9f1e33a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through all of the changes and made a comment on any change that was not just a formatting change to make reviewing a bit easier.
@@ -250,9 +264,9 @@ impl<'a> Metrics<'a> { | |||
} | |||
|
|||
fn diffs(&self) -> Vec<f64> { | |||
let mut diff = vec!(0.0; (self.len - 1) as usize); | |||
let mut diff = vec![0.0; (self.len - 1) as usize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy update, macros can be invoked using [], (), or {} so this is not functionally any different
@@ -270,7 +277,7 @@ pub mod prefix_varint { | |||
let tag_byte = value[0]; | |||
if tag_byte & 1 == 1 { | |||
let value = (tag_byte >> 1) as u64; | |||
return (value, 1) | |||
return (value, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if this is clippy or fmt but its functionally the same
Slice::Slice(s) => { | ||
*self = Slice::Owned(s.to_vec()); | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: When using braces in match statements, rustfmt will remove commas. Not a clippy change.
@@ -962,7 +962,7 @@ mod tests { | |||
.chain(batch2.iter()) | |||
.chain(batch3.iter()) | |||
.chain(batch4.iter()) | |||
.map(|x| *x) | |||
.copied() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy change: .copied()
creates an iterator which copies all of its elements. This is a cleaner way of doing .map(|x| *x)
before .collect()
let mut root_client = Client::connect(&*root_connection_config, NoTls) | ||
.expect("could not connect to postgres"); | ||
let mut root_client = | ||
Client::connect(root_connection_config, NoTls).expect("could not connect to postgres"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems functionally the same
528: Clippy Suggestions Across Workspaces r=thatzopoulos a=thatzopoulos This PR contains Clippy changes and should be merged before the Cargo Fmt PR: #524 Co-authored-by: Thomas Hatzopoulos <[email protected]>
dd7da97
to
f1b77a9
Compare
3385020
to
8b50127
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To go along with a few minor comments I had, I'd like to very timidly propose max_width = 120
. There's several places where I feel like we get bitten by line length (of course this is a symptom of using formatting tools and it will never be perfect).
Approving because I don't think anything I've seen is worth holding up the PR over
"SELECT toolkit_experimental.anything(val) \ | ||
let output = client | ||
.select( | ||
"SELECT toolkit_experimental.anything(val) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's worth doing (in this PR or at all) but this is one of SEVERAL places where rustfmt
makes the SQL statement inside the string have a peculiar alignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the answer is to use raw string literals and align manually. We have some of those already, as well as some use of raw that still doesn't have clean alignment.
I think we should isolate rustfmt changes to one commit, so if Thomas does feel like doing anything about this right now, let's do it before or after this.
But I think it can just wait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along these lines, I suggest NOT squashing this, but keeping the three commits you have now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I've at least "glanced" at everything now. Seems OK to me!
extension/src/stats_agg.rs
Outdated
(None, None) => Some(StatsSummary2D::from_internal(InternalStatsSummary2D::new()).into()), // return an empty one from the trans function because otherwise it breaks in the window context | ||
(None, None) => { | ||
Some(StatsSummary2D::from_internal(InternalStatsSummary2D::new()).into()) | ||
} // return an empty one from the trans function because otherwise it breaks in the window context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could turn this into
...
// return an empty one from the trans function because otherwise it breaks in the window context
Some(StatsSummary2D::from_internal(InternalStatsSummary2D::new()).into())
}
if it's not too much trouble
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to reviewer comments commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My eyes are bleeding now, but let's do it!
"SELECT toolkit_experimental.anything(val) \ | ||
let output = client | ||
.select( | ||
"SELECT toolkit_experimental.anything(val) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the answer is to use raw string literals and align manually. We have some of those already, as well as some use of raw that still doesn't have clean alignment.
I think we should isolate rustfmt changes to one commit, so if Thomas does feel like doing anything about this right now, let's do it before or after this.
But I think it can just wait.
#![allow(clippy::extra_unused_lifetimes)] // some disagreement between clippy and the rust compiler about when lifetime are and are not needed | ||
#![allow(clippy::not_unsafe_ptr_arg_deref)] // every function calling in_aggregate_context should be unsafe | ||
#![allow(clippy::modulo_one)] | ||
// flat_serialize! alignment checks hit this for any single byte field (of which all pg_types! have two by default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these comments now apply to the wrong line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to reviewer comments commit.
b89888b
to
11edf5b
Compare
bors r+ |
Build succeeded: |
532: Adding git-blame-ignore-revs file r=thatzopoulos a=thatzopoulos Part 2 of updating toolkit to use `cargo fmt` by uploading `.git-blame-ignore-revs` with the `cargo fmt` commits in the file. Part 1 can be found here: #524 You can use git config to set git to always use the ignoreRevsFile in a project with the following command: ``` git config blame.ignoreRevsFile .git-blame-ignore-revs ``` You could also just pass it in as a flag to git blame but then you have to remember to always include the flag. ``` git blame --ignore-revs-file .git-blame-ignore-revs ``` Co-authored-by: Thomas Hatzopoulos <[email protected]>
Part 1 of updating toolkit to use cargo fmt.
Once this is merged, we will need to store the merge commit from this PR in a file in the repo so that we can set up git blame to ignore this commit:
Create file .git-blame-ignore-revs:
You can use git config to set git to always use the ignoreRevsFile in a project with the following command:
git config blame.ignoreRevsFile .git-blame-ignore-revs
You could also just pass it in as a flag to git blame but then you have to remember to always include the flag.