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

Updating Toolkit To Start Using Cargo Fmt #524

Merged
merged 3 commits into from Sep 12, 2022
Merged

Conversation

thatzopoulos
Copy link
Contributor

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:

# Example Commit
864343aaa7d7e72d8e336d8bb8778d4f49846af9

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

@thatzopoulos thatzopoulos marked this pull request as ready for review September 6, 2022 20:51
@thatzopoulos thatzopoulos force-pushed the th/cargo-fmt-all-workspaces branch 2 times, most recently from 7f238c5 to 9f1e33a Compare September 7, 2022 16:26
Copy link
Contributor Author

@thatzopoulos thatzopoulos left a 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];
Copy link
Contributor Author

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);
Copy link
Contributor Author

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

crates/flat_serialize/flat_serialize/src/lib.rs Outdated Show resolved Hide resolved
Slice::Slice(s) => {
*self = Slice::Owned(s.to_vec());
},
}
Copy link
Contributor Author

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.

crates/hyperloglogplusplus/src/dense.rs Outdated Show resolved Hide resolved
@@ -962,7 +962,7 @@ mod tests {
.chain(batch2.iter())
.chain(batch3.iter())
.chain(batch4.iter())
.map(|x| *x)
.copied()
Copy link
Contributor Author

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()

crates/udd-sketch/src/lib.rs Outdated Show resolved Hide resolved
tools/sql-doctester/src/runner.rs Outdated Show resolved Hide resolved
tools/testrunner/src/main.rs Outdated Show resolved Hide resolved
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");
Copy link
Contributor Author

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

bors bot added a commit that referenced this pull request Sep 8, 2022
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 <thomas@timescale.com>
Copy link
Contributor

@rtwalker rtwalker left a 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

crates/asap/src/lib.rs Show resolved Hide resolved
crates/counter-agg/src/lib.rs Outdated Show resolved Hide resolved
"SELECT toolkit_experimental.anything(val) \
let output = client
.select(
"SELECT toolkit_experimental.anything(val) \
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@rtwalker rtwalker left a 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!

(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
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@epgts epgts left a 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) \
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@thatzopoulos
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 12, 2022

@bors bors bot merged commit b743334 into main Sep 12, 2022
@bors bors bot deleted the th/cargo-fmt-all-workspaces branch September 12, 2022 17:10
bors bot added a commit that referenced this pull request Sep 12, 2022
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 <thomas@timescale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants