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

Chore: cargo clippy and cargo fmt #110

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.77.1

jobs:
build:
Expand All @@ -20,3 +21,28 @@ jobs:
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

cargo-fmt-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt
- name: Check Formatting
run: cargo fmt --all -- --check

cargo-clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Check Clippy Linter
run: cargo clippy --all-features --all-targets -- -D warnings
47 changes: 31 additions & 16 deletions examples/multifile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ariadne::{Report, ReportKind, Label, ColorGenerator, Fmt, sources};
use ariadne::{sources, ColorGenerator, Fmt, Label, Report, ReportKind};

fn main() {
let mut colors = ColorGenerator::new();
Expand All @@ -10,21 +10,36 @@ fn main() {

Report::build(ReportKind::Error, "b.tao", 10)
.with_code(3)
.with_message(format!("Cannot add types Nat and Str"))
.with_label(Label::new(("b.tao", 10..14))
.with_message(format!("This is of type {}", "Nat".fg(a)))
.with_color(a))
.with_label(Label::new(("b.tao", 17..20))
.with_message(format!("This is of type {}", "Str".fg(b)))
.with_color(b))
.with_label(Label::new(("b.tao", 15..16))
.with_message(format!(" {} and {} undergo addition here", "Nat".fg(a), "Str".fg(b)))
.with_color(c)
.with_order(10))
.with_label(Label::new(("a.tao", 4..8))
.with_message(format!("Original definition of {} is here", "five".fg(a)))
.with_color(a))
.with_note(format!("{} is a number and can only be added to other numbers", "Nat".fg(a)))
.with_message("Cannot add types Nat and Str".to_string())
.with_label(
Label::new(("b.tao", 10..14))
.with_message(format!("This is of type {}", "Nat".fg(a)))
.with_color(a),
)
.with_label(
Label::new(("b.tao", 17..20))
.with_message(format!("This is of type {}", "Str".fg(b)))
.with_color(b),
)
.with_label(
Label::new(("b.tao", 15..16))
.with_message(format!(
" {} and {} undergo addition here",
"Nat".fg(a),
"Str".fg(b)
))
.with_color(c)
.with_order(10),
)
.with_label(
Label::new(("a.tao", 4..8))
.with_message(format!("Original definition of {} is here", "five".fg(a)))
.with_color(a),
)
.with_note(format!(
"{} is a number and can only be added to other numbers",
"Nat".fg(a)
))
.finish()
.print(sources(vec![
("a.tao", include_str!("a.tao")),
Expand Down
63 changes: 35 additions & 28 deletions examples/multiline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ariadne::{Report, ReportKind, Label, Source, Color, ColorGenerator, Fmt};
use ariadne::{Color, ColorGenerator, Fmt, Label, Report, ReportKind, Source};

fn main() {
let mut colors = ColorGenerator::new();
Expand All @@ -7,36 +7,43 @@ fn main() {
let a = colors.next();
let b = colors.next();
let out = Color::Fixed(81);
let out2= colors.next();
let out2 = colors.next();

Report::build(ReportKind::Error, "sample.tao", 12)
.with_code(3)
.with_message(format!("Incompatible types"))
.with_label(Label::new(("sample.tao", 32..33))
.with_message(format!("This is of type {}", "Nat".fg(a)))
.with_color(a))
.with_label(Label::new(("sample.tao", 42..45))
.with_message(format!("This is of type {}", "Str".fg(b)))
.with_color(b))
.with_label(Label::new(("sample.tao", 11..48))
.with_message(format!(
"The values are outputs of this {} expression",
"match".fg(out),
))
.with_color(out))
.with_label(Label::new(("sample.tao", 0..48))
.with_message(format!(
"The {} has a problem",
"definition".fg(out2),
))
.with_color(out2))
.with_label(Label::new(("sample.tao", 50..76))
.with_message(format!(
"Usage of {} here",
"definition".fg(out2),
))
.with_color(out2))
.with_note(format!("Outputs of {} expressions must coerce to the same type", "match".fg(out)))
.with_message("Incompatible types".to_string())
.with_label(
Label::new(("sample.tao", 32..33))
.with_message(format!("This is of type {}", "Nat".fg(a)))
.with_color(a),
)
.with_label(
Label::new(("sample.tao", 42..45))
.with_message(format!("This is of type {}", "Str".fg(b)))
.with_color(b),
)
.with_label(
Label::new(("sample.tao", 11..48))
.with_message(format!(
"The values are outputs of this {} expression",
"match".fg(out),
))
.with_color(out),
)
.with_label(
Label::new(("sample.tao", 0..48))
.with_message(format!("The {} has a problem", "definition".fg(out2),))
.with_color(out2),
)
.with_label(
Label::new(("sample.tao", 50..76))
.with_message(format!("Usage of {} here", "definition".fg(out2),))
.with_color(out2),
)
.with_note(format!(
"Outputs of {} expressions must coerce to the same type",
"match".fg(out)
))
.finish()
.print(("sample.tao", Source::from(include_str!("sample.tao"))))
.unwrap();
Expand Down
15 changes: 12 additions & 3 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ariadne::{Report, ReportKind, Label, Source, Config, Color};
use ariadne::{Color, Config, Label, Report, ReportKind, Source};

fn main() {
Report::build(ReportKind::Error, (), 34)
Expand All @@ -15,9 +15,18 @@ fn main() {
.with_message("Incompatible types")
.with_config(Config::default().with_compact(true))
.with_label(Label::new(0..1).with_color(Color::Red))
.with_label(Label::new(2..3).with_color(Color::Blue).with_message("`b` for banana").with_order(1))
.with_label(
Label::new(2..3)
.with_color(Color::Blue)
.with_message("`b` for banana")
.with_order(1),
)
.with_label(Label::new(4..5).with_color(Color::Green))
.with_label(Label::new(7..9).with_color(Color::Cyan).with_message("`e` for emerald"))
.with_label(
Label::new(7..9)
.with_color(Color::Cyan)
.with_message("`e` for emerald"),
)
.finish()
.print(Source::from(SOURCE))
.unwrap();
Expand Down
Loading
Loading