Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request geiger-rs#17 from anderejd/new_default_scan_mode
Browse files Browse the repository at this point in the history
New default scan mode
  • Loading branch information
anderejd authored Jul 18, 2018
2 parents 4816987 + e54796f commit 1d6fc7d
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 234 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cargo-geiger"
description = "Detects usage of unsafe Rust in your project and its dependencies."
version = "0.2.0"
version = "0.3.0"
authors = ["anderejd <[email protected]>"]
repository = "https://github.com/anderejd/cargo-geiger"
readme = "README.md"
Expand Down
34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@ Usage
1. `cargo install cargo-geiger`
2. Navigate to the same directory as the Cargo.toml you want to analyze.
3. `cargo geiger`
4. Please don't look at the `--help` flags, they are inherited from cargo-tree
and may not work as intended. TODO: Review and update command line flags.


Output examples
---------------

### Default output format:
![Example output (default)](cargo-geiger-example-output-default.png)

### With `--compact`:
![Example output (using --compact)](cargo-geiger-example-output-compact.png)
![Example output](https://user-images.githubusercontent.com/3704611/42893683-54f16930-8ab5-11e8-87a5-785fe4a1d5d9.png)


Why even care about unsafe Rust usage?
Expand Down Expand Up @@ -55,31 +50,42 @@ inevitable in some situations and both should preferably be safely contained!
Known issues
------------

- Crates with nested crates can currently report inaccurate stats.
- Both base projects, cargo-tree and cargo-osha could be depended on if
refactored into library and application parts.
- Unsafe code inside macros are not detected. Needs macro expansion(?).
- Unsafe code generated by `build.rs` are probably not detected.
- Error handling is missing for the most part and there are plenty of panics lurking.
- Proper logging should be sorted out.
- Command line flags needs review and refactoring for this project.
- Command line flags needs some more review and refactoring for this project.
- Will continue on syn parse errors. Needs a new command line flag and should
default to exit on errors(?).
- Could probably benefit from parallelization. One `.rs` file per core should
be parsed at all times.
- More on the github issue tracker.


Roadmap
-------

- Refactoring and general cleanup.
- Proper error handling using Result.
- An optional whitelist file at the root crate level to specify crates that are
trusted to use unsafe (should only have an effect if placed in the root
project).
- More and better ways to analyse unsafe usage
- Improved output format?
- Additional output formats?
- Fixing known issues! :)
- Additional output formats


Changelog
---------

### 0.3.0
- Intercepts `rustc` calls and reads the `.d` files generated by `rustc` to
identify which `.rs` files are used by the build. This allows a crate that
contains `.rs` files with unsafe code usage to pass as "green" if the unsafe
code isn't used by the build.
- Each metric is now printed as `x/y`, where `x` is the unsafe code used by the
build and `y` is the total unsafe usage found in the crate.
- Removed the `--compact` output format to avoid some code complexity. A new
and better compact mode can be added later if requested.

### 0.2.0
- (alexmaco) Table based default output format. Old format still available by
`--compact`.
Expand Down
Binary file removed cargo-geiger-example-output-compact.png
Binary file not shown.
Binary file removed cargo-geiger-example-output-default.png
Binary file not shown.
4 changes: 2 additions & 2 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ impl Pattern {
) -> Display<'a> {
Display {
pattern: self,
package: package,
metadata: metadata,
package,
metadata,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Parser<'a> {
impl<'a> Parser<'a> {
pub fn new(s: &'a str) -> Parser<'a> {
Parser {
s: s,
s,
it: s.char_indices().peekable(),
}
}
Expand Down
Loading

0 comments on commit 1d6fc7d

Please sign in to comment.