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

NOISSUE - Refactoring geiger lib and adding further testing #158

Merged
merged 1 commit into from
Dec 6, 2020

Conversation

jmcconnell26
Copy link
Contributor

Signed-off-by: joshmc josh-mcc@tiscali.co.uk

Comment on lines 7 to 22
pub struct GeigerSynVisitor {
/// Count unsafe usage inside tests
pub include_tests: IncludeTests,

/// The resulting data from a single file scan.
pub metrics: RsFileMetrics,

/// The number of nested unsafe scopes that the GeigerSynVisitor are
/// currently in. For example, if the visitor is inside an unsafe function
/// and inside an unnecessary unsafe block inside that function, then this
/// number should be 2. If the visitor is outside unsafe scopes, in a safe
/// scope, this number should be 0.
/// This is needed since unsafe scopes can be nested and we need to know
/// when we leave the outmost unsafe scope and get back into a safe scope.
pub unsafe_scopes: u32,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep the members on this struct private or will that result in too much bloat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, it looks like the include_tests and unsafe_scopes can definitely be (my bad being too keen with the refactoring). I think the metrics needs to be public at the crate level (it's called in the newly created find module), but it should be restricted to that by https://github.com/rust-secure-code/cargo-geiger/pull/158/files#diff-a49da58edbe4631a734dcd7884f75469e5ee8ab7859659643656a113c9b2ee81R11 however I'm more than happy to add a pub crate restriction to it, to make explicit the exposure level?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm more than happy to add a pub crate restriction to it, to make explicit the exposure level?

Not needed on my opinion. The reason I wanted to restrict the other members was to avoid accidental coupling between different modules down the line. Keeping internal API:s inside a library clear and minimal tends to make maintenance and refactoring easier in the long run, in my experience.

Comment on lines +81 to +82
.count()
> 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Since CI passes this is following rustfmt standard, but still very strange formatting style to use a newline here imho... :)

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 actually went back and had a go at setting it explicitly to .count() > 0 but it appears cargo fmt seems to update it to be like this.
Do you think its worth looking into the cargo fmt settings, or do you reckon it's OK like this?

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 what rustfmt does, let's go with that.

* Making inner members of struct geiger_syn_visitor private where
  possible

Signed-off-by: joshmc <josh-mcc@tiscali.co.uk>
@anderejd anderejd merged commit dfc6ccb into geiger-rs:master Dec 6, 2020
@jmcconnell26 jmcconnell26 deleted the NOISSUE-RefactorGeigerLib branch December 6, 2020 12:06
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

2 participants