Skip to content

Commit

Permalink
Add clippy.toml and fix public lint issues (maplibre#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik authored Jan 25, 2025
1 parent 13d9966 commit c0327ba
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 13 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:
mv target/$target/release/mbtiles target_releases/$target
done
- name: Save build artifacts to build-${{ matrix.target }}
- name: Save cross-build artifacts
uses: actions/upload-artifact@v4
with:
name: cross-build
Expand Down Expand Up @@ -213,6 +213,16 @@ jobs:
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=require

- name: Save test output (on error)
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-test-output-docker
path: |
tests/output/*
target/test_logs/*
retention-days: 5

- name: Login to GitHub Docker registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ unused_qualifications = "warn"
[workspace.lints.clippy]
pedantic = { level = "warn", priority = -1 }
derive_partial_eq_without_eq = "allow"
enum_variant_names = "allow"
implicit_hasher = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
struct_field_names = "allow"

[workspace.dependencies]
actix-cors = "0.7"
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
avoid-breaking-exported-api = false
8 changes: 4 additions & 4 deletions martin/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ impl Config {
}

#[cfg(feature = "pmtiles")]
res.extend(self.pmtiles.finalize("pmtiles.")?);
res.extend(self.pmtiles.finalize("pmtiles."));

#[cfg(feature = "mbtiles")]
res.extend(self.mbtiles.finalize("mbtiles.")?);
res.extend(self.mbtiles.finalize("mbtiles."));

#[cfg(feature = "cog")]
res.extend(self.cog.finalize("cog.")?);
res.extend(self.cog.finalize("cog."));

#[cfg(feature = "sprites")]
res.extend(self.sprites.finalize("sprites.")?);
res.extend(self.sprites.finalize("sprites."));

// TODO: support for unrecognized fonts?
// res.extend(self.fonts.finalize("fonts.")?);
Expand Down
4 changes: 2 additions & 2 deletions martin/src/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ impl<T: ConfigExtras> FileConfigEnum<T> {
Ok(Some(res))
}

pub fn finalize(&self, prefix: &str) -> MartinResult<UnrecognizedValues> {
pub fn finalize(&self, prefix: &str) -> UnrecognizedValues {
let mut res = UnrecognizedValues::new();
if let Self::Config(cfg) = self {
copy_unrecognized_config(&mut res, prefix, cfg.get_unrecognized());
}
Ok(res)
res
}
}

Expand Down
2 changes: 1 addition & 1 deletion martin/src/mbtiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {
path: https://example.org/file4.ext
"})
.unwrap();
let res = cfg.finalize("").unwrap();
let res = cfg.finalize("");
assert!(res.is_empty(), "unrecognized config: {res:?}");
let FileConfigEnum::Config(cfg) = cfg else {
panic!();
Expand Down
2 changes: 1 addition & 1 deletion mbtiles/src/copier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum CopyDuplicateMode {

impl CopyDuplicateMode {
#[must_use]
pub fn to_sql(&self) -> &'static str {
pub fn to_sql(self) -> &'static str {
match self {
CopyDuplicateMode::Override => "OR REPLACE",
CopyDuplicateMode::Ignore => "OR IGNORE",
Expand Down
4 changes: 2 additions & 2 deletions mbtiles/src/mbtiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ pub enum CopyType {

impl CopyType {
#[must_use]
pub fn copy_tiles(&self) -> bool {
pub fn copy_tiles(self) -> bool {
matches!(self, Self::All | Self::Tiles)
}
#[must_use]
pub fn copy_metadata(&self) -> bool {
pub fn copy_metadata(self) -> bool {
matches!(self, Self::All | Self::Metadata)
}
}
Expand Down
4 changes: 2 additions & 2 deletions mbtiles/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ pub enum MbtType {

impl MbtType {
#[must_use]
pub fn is_normalized(&self) -> bool {
pub fn is_normalized(self) -> bool {
matches!(self, Self::Normalized { .. })
}

#[must_use]
pub fn is_normalized_with_view(&self) -> bool {
pub fn is_normalized_with_view(self) -> bool {
matches!(self, Self::Normalized { hash_view: true })
}
}
Expand Down

0 comments on commit c0327ba

Please sign in to comment.