Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

warnings as errors #583

Merged
merged 14 commits into from
Feb 15, 2019
Merged

warnings as errors #583

merged 14 commits into from
Feb 15, 2019

Conversation

eauge
Copy link
Contributor

@eauge eauge commented Feb 14, 2019

Address issue https://github.com/oasislabs/runtime-ethereum/issues/525

The best mechanism I've seen for now is to add #![deny(warnings)] in the top lib.rs file. I've seen that they are working on supporting a lint directive in the cargo.toml file but there's nothing yet rust-lang/cargo#5034

@eauge eauge force-pushed the eauge/lint/warnings-as-errors branch from 8065664 to 7dad571 Compare February 14, 2019 01:15
@@ -41,56 +39,6 @@ impl KeyManagerClient {
}
}

/// Wrapper around the Ekiden key manager client to provide a more convenient
/// Ethereum address based interface along with runtime-specific utility methods.
struct KeyManager;
Copy link
Contributor

Choose a reason for hiding this comment

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

What made you delete this? We still need it. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was just not being used

Copy link
Contributor

Choose a reason for hiding this comment

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

This is definitely used. See KeyManagerClient. We do some conditional compilation for testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

The e2e tests will fail if this is deleted.

.gitignore Outdated
@@ -1,7 +1,7 @@
# Mac things
.DS_Store

# Build.
n# Build.
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 you added this by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, let me fix it

.gitignore Outdated

# in case credentials are put in the repo for using
# inside the docker container
.git-credentials
Copy link
Contributor

Choose a reason for hiding this comment

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

Newline.

@armaniferrante
Copy link
Contributor

armaniferrante commented Feb 14, 2019

We should reconsider whether we want to use #![deny(warnings)] https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md

At first glance, I think I'm ok with it.

@eauge
Copy link
Contributor Author

eauge commented Feb 14, 2019

@armaniferrante that looks like a good alternative. Is there a specific set of warnings that you'd rather deny, like the one suggested in that link that the author says it's safe to deny? Or still deny all warnings?

@eauge eauge force-pushed the eauge/lint/warnings-as-errors branch 16 times, most recently from 068fb77 to 51becc5 Compare February 14, 2019 23:25
api/build.rs Outdated
@@ -1,3 +1,5 @@
//! build crate for the ekiden api
Copy link
Contributor

Choose a reason for hiding this comment

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

All comments should start with capitalization and end with periods.

extern crate rayon;
extern crate regex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Look at all of these removed crates. Glorious. Are they removed from Cargo.toml as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't, but we could do that. I would prefer to do it in a separate PR if that's okay though :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why another PR? Might as well do it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me try then

@@ -0,0 +1,32 @@
#
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity is this an exhaustive list? I assume not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got the list from here https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md. It's not exhaustive since rust still adds/deprecates lints with quite some frequency. Based on that post, it looks like this is a reasonable set. Let me know if there's any other lint that you think should be added

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 this is great to start. We can add/subtract as necessary in the future.

@@ -86,9 +85,11 @@ pub trait ChainNotify: Send + Sync {
pub struct Client {
client: runtime_ethereum::Client,
engine: Arc<EthEngine>,
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is dead can we delete it?

Copy link
Contributor

@armaniferrante armaniferrante left a comment

Choose a reason for hiding this comment

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

This all looks good to me. The only gripe I have is the usage of #[allow(dead_code)]. If possible, let's either delete such code or switch it to a conditional compilation. Let me know if neither are possible.

@eauge eauge force-pushed the eauge/lint/warnings-as-errors branch 2 times, most recently from fc8e426 to 50ff694 Compare February 15, 2019 18:59
@eauge
Copy link
Contributor Author

eauge commented Feb 15, 2019

@armaniferrante this is the error that we get if we don't allow dead_code for the key manager when running the cargo tests.

error: struct is never constructed: `KeyManager`
--
  | --> common/src/confidential/key_manager.rs:47:1
  | \|
  | 47 \| struct KeyManager;
  | \| ^^^^^^^^^^^^^^^^^^
  | \|
  | = note: requested on the command line with `-D dead-code`

Let me know if there's a better way to fix this, otherwise we will have to live with allow dead code for now.

@eauge eauge force-pushed the eauge/lint/warnings-as-errors branch from 50ff694 to 37e861f Compare February 15, 2019 19:25
@armaniferrante
Copy link
Contributor

Discussed offline. The conditional compilation for the KeyManager fixed the warnings. We don't need #[allow(dead_code)] there.

@eauge eauge force-pushed the eauge/lint/warnings-as-errors branch from 37e861f to 51f0211 Compare February 15, 2019 19:37
@eauge eauge force-pushed the eauge/lint/warnings-as-errors branch 8 times, most recently from f50b47e to ca163f3 Compare February 15, 2019 23:13
@eauge eauge force-pushed the eauge/lint/warnings-as-errors branch from ca163f3 to 69aad5d Compare February 15, 2019 23:18
@@ -1,3 +1,5 @@
//! build crate for the ekiden runtime based enclave
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//! build crate for the ekiden runtime based enclave
//! Build crate for the ekiden runtime based enclave.

Copy link
Contributor

@armaniferrante armaniferrante left a comment

Choose a reason for hiding this comment

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

LGTM.

@armaniferrante
Copy link
Contributor

Filed https://github.com/oasislabs/runtime-ethereum/issues/590 as a followup to turn on "unused results".

@eauge eauge merged commit 8062738 into master Feb 15, 2019
@kostko kostko deleted the eauge/lint/warnings-as-errors branch May 21, 2019 08:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants