Skip to content

Datatype Copy Rust's Structure #195

Datatype Copy Rust's Structure

Datatype Copy Rust's Structure #195

Triggered via pull request September 3, 2023 10:09
Status Success
Total duration 7m 8s
Artifacts

ci.yml

on: pull_request
Matrix: build
Fit to window
Zoom out
Zoom in

Annotations

28 warnings
useless conversion to the same type: `datatype::r#enum::EnumType`: src/type/impls.rs#L315
warning: useless conversion to the same type: `datatype::r#enum::EnumType` --> src/type/impls.rs:315:17 | 315 | / EnumType { 316 | | name: "Number".into(), 317 | | repr: EnumRepr::Untagged, 318 | | variants: vec![ ... | 351 | | } 352 | | .into(), | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion help: consider removing `.into()` | 315 ~ EnumType { 316 + name: "Number".into(), 317 + repr: EnumRepr::Untagged, 318 + variants: vec![ 319 + ( 320 + "f64".into(), 321 + EnumVariant::Unnamed(UnnamedFields { 322 + fields: vec![Field { 323 + optional: false, 324 + flatten: false, 325 + ty: DataType::Primitive(PrimitiveType::f64), 326 + }], 327 + }), 328 + ), 329 + ( 330 + "i64".into(), 331 + EnumVariant::Unnamed(UnnamedFields { 332 + fields: vec![Field { 333 + optional: false, 334 + flatten: false, 335 + ty: DataType::Primitive(PrimitiveType::i64), 336 + }], 337 + }), 338 + ), 339 + ( 340 + "u64".into(), 341 + EnumVariant::Unnamed(UnnamedFields { 342 + fields: vec![Field { 343 + optional: false, 344 + flatten: false, 345 + ty: DataType::Primitive(PrimitiveType::u64), 346 + }], 347 + }), 348 + ), 349 + ], 350 + generics: vec![], 351 ~ }, |
useless conversion to the same type: `datatype::r#enum::EnumType`: src/type/impls.rs#L249
warning: useless conversion to the same type: `datatype::r#enum::EnumType` --> src/type/impls.rs:249:17 | 249 | / EnumType { 250 | | name: "Number".into(), 251 | | repr: EnumRepr::Untagged, 252 | | variants: vec![ ... | 285 | | } 286 | | .into(), | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion help: consider removing `.into()` | 249 ~ EnumType { 250 + name: "Number".into(), 251 + repr: EnumRepr::Untagged, 252 + variants: vec![ 253 + ( 254 + "f64".into(), 255 + EnumVariant::Unnamed(UnnamedFields { 256 + fields: vec![Field { 257 + optional: false, 258 + flatten: false, 259 + ty: DataType::Primitive(PrimitiveType::f64), 260 + }], 261 + }), 262 + ), 263 + ( 264 + "i64".into(), 265 + EnumVariant::Unnamed(UnnamedFields { 266 + fields: vec![Field { 267 + optional: false, 268 + flatten: false, 269 + ty: DataType::Primitive(PrimitiveType::i64), 270 + }], 271 + }), 272 + ), 273 + ( 274 + "u64".into(), 275 + EnumVariant::Unnamed(UnnamedFields { 276 + fields: vec![Field { 277 + optional: false, 278 + flatten: false, 279 + ty: DataType::Primitive(PrimitiveType::u64), 280 + }], 281 + }), 282 + ), 283 + ], 284 + generics: vec![], 285 ~ }, |
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L516
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:516:40 | 516 | let field_name_safe = sanitise_key(&key, false); | ^^^^ help: change this to: `key` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
using a reference to `Cow` is not recommended: src/lang/ts/mod.rs#L512
warning: using a reference to `Cow` is not recommended --> src/lang/ts/mod.rs:512:10 | 512 | key: &Cow<'static, str>, | ^^^^^^^^^^^^^^^^^^ help: change this to: `&str` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L477
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:477:33 | 477 | ... &v, | ^^ help: change this to: `v` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L463
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:463:33 | 463 | ... &v, | ^^ help: change this to: `v` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L446
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:446:45 | 446 | ... &name, | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
length comparison to zero: src/lang/ts/mod.rs#L392
warning: length comparison to zero --> src/lang/ts/mod.rs:392:8 | 392 | if e.variants().len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `e.variants().is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
useless use of `format!`: src/lang/ts/mod.rs#L384
warning: useless use of `format!` --> src/lang/ts/mod.rs:384:28 | 384 | [field] => format!("{}", field), | ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `field.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format = note: `#[warn(clippy::useless_format)]` implied by `#[warn(clippy::all)]`
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L362
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:362:29 | 362 | ... &name, | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L350
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:350:51 | 350 | let sanitised_name = sanitise_key(&name, true); | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
using a reference to `Cow` is not recommended: src/lang/ts/mod.rs#L342
warning: using a reference to `Cow` is not recommended --> src/lang/ts/mod.rs:342:11 | 342 | name: &Cow<'static, str>, | ^^^^^^^^^^^^^^^^^^ help: change this to: `&str` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L322
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:322:80 | 322 | object_field_to_ts(ctx.with(PathItem::Field(key.clone())), &key, f, type_map) | ^^^^ help: change this to: `key` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` implied by `#[warn(clippy::all)]`
length comparison to zero: src/lang/ts/mod.rs#L298
warning: length comparison to zero --> src/lang/ts/mod.rs:298:16 | 298 | if s.fields.len() == 0 { | ^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.fields.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero = note: `#[warn(clippy::len_zero)]` implied by `#[warn(clippy::all)]`
using a reference to `Cow` is not recommended: src/lang/ts/mod.rs#L290
warning: using a reference to `Cow` is not recommended --> src/lang/ts/mod.rs:290:10 | 290 | key: &Cow<'static, str>, | ^^^^^^^^^^^^^^^^^^ help: change this to: `&str` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
unneeded `return` statement: src/lang/ts/mod.rs#L295
warning: unneeded `return` statement --> src/lang/ts/mod.rs:295:31 | 295 | StructFields::Unit => return Ok("null".into()), | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` implied by `#[warn(clippy::all)]` help: remove `return` | 295 | StructFields::Unit => Ok("null".into()), | ~~~~~~~~~~~~~~~~~
this match could be written as a `let` statement: src/lang/ts/mod.rs#L273
warning: this match could be written as a `let` statement --> src/lang/ts/mod.rs:273:5 | 273 | / match tuple { 274 | | TupleType { fields, .. } => match &fields[..] { 275 | | [] => Ok(empty_tuple_fallback.to_string()), 276 | | [ty] => datatype_inner(ctx, ty, type_map, "null"), ... | 284 | | }, 285 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding = note: `#[warn(clippy::match_single_binding)]` implied by `#[warn(clippy::all)]` help: consider using a `let` statement | 273 ~ let TupleType { fields, .. } = tuple; 274 + match &fields[..] { 275 + [] => Ok(empty_tuple_fallback.to_string()), 276 + [ty] => datatype_inner(ctx, ty, type_map, "null"), 277 + tys => Ok(format!( 278 + "[{}]", 279 + tys.iter() 280 + .map(|v| datatype_inner(ctx.clone(), v, type_map, "null")) 281 + .collect::<Result<Vec<_>>>()? 282 + .join(", ") 283 + )), 284 + } |
writing `&Vec` instead of `&[_]` involves a new object where a slice will do: src/lang/ts/mod.rs#L249
warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do --> src/lang/ts/mod.rs:249:13 | 249 | fields: &Vec<Field>, | ^^^^^^^^^^^ help: change this to: `&[Field]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: `#[warn(clippy::ptr_arg)]` implied by `#[warn(clippy::all)]`
`panic` should not be present in production code: src/lang/ts/mod.rs#L178
warning: `panic` should not be present in production code --> src/lang/ts/mod.rs:178:44 | 178 | .unwrap_or_else(|| panic!("Type {} has no value!", r.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic
`panic` should not be present in production code: src/lang/ts/mod.rs#L176
warning: `panic` should not be present in production code --> src/lang/ts/mod.rs:176:44 | 176 | .unwrap_or_else(|| panic!("Type {} not found!", r.name())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic note: the lint level is defined here --> src/lib.rs:58:43 | 58 | #![warn(clippy::all, clippy::unwrap_used, clippy::panic)] // TODO: missing_docs | ^^^^^^^^^^^^^
useless conversion to the same type: `export::export::TypesIter`: src/export/ts.rs#L19
warning: useless conversion to the same type: `export::export::TypesIter` --> src/export/ts.rs:19:17 | 19 | let types = get_types()? | _________________^ 20 | | .into_iter() | |____________________^ help: consider removing `.into_iter()`: `get_types()?` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
useless conversion to the same type: `r#type::ExportError`: src/export/export.rs#L38
warning: useless conversion to the same type: `r#type::ExportError` --> src/export/export.rs:38:20 | 38 | return Err(err.clone().into()); | ^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `err.clone()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
module has the same name as its containing module: src/export/mod.rs#L1
warning: module has the same name as its containing module --> src/export/mod.rs:1:1 | 1 | mod export; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception = note: `#[warn(clippy::module_inception)]` implied by `#[warn(clippy::all)]`
useless conversion to the same type: `datatype::r#enum::EnumType`: src/datatype/mod.rs#L132
warning: useless conversion to the same type: `datatype::r#enum::EnumType` --> src/datatype/mod.rs:132:13 | 132 | / EnumType { 133 | | name: "Vec".into(), 134 | | repr: EnumRepr::Untagged, 135 | | variants: t ... | 157 | | } 158 | | .into(), | |___________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` implied by `#[warn(clippy::all)]` help: consider removing `.into()` | 132 ~ EnumType { 133 + name: "Vec".into(), 134 + repr: EnumRepr::Untagged, 135 + variants: t 136 + .into_iter() 137 + .map(|t| { 138 + let ty: DataType = t.into(); 139 + ( 140 + match &ty { 141 + DataType::Struct(s) => s.name.clone(), 142 + DataType::Enum(e) => e.name().clone(), 143 + // TODO: This is probs gonna cause problems so we should try and remove the need for this entire impl block if we can. 144 + _ => "".into(), 145 + }, 146 + EnumVariant::Unnamed(UnnamedFields { 147 + fields: vec![Field { 148 + optional: false, 149 + flatten: false, 150 + ty, 151 + }], 152 + }), 153 + ) 154 + }) 155 + .collect(), 156 + generics: vec![], 157 ~ }, |
constant `RESERVED_IDENTS` is never used: src/lang/ts/reserved_terms.rs#L66
warning: constant `RESERVED_IDENTS` is never used --> src/lang/ts/reserved_terms.rs:66:18 | 66 | pub(super) const RESERVED_IDENTS: &[&str] = &[ | ^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
unneeded unit return type: src/export/export.rs#L49
warning: unneeded unit return type --> src/export/export.rs:49:30 | 49 | pub fn register_ty<T: Type>() -> () { | ^^^^^^ help: remove the `-> ()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit note: the lint level is defined here --> src/lib.rs:58:9 | 58 | #![warn(clippy::all, clippy::unwrap_used, clippy::panic)] // TODO: missing_docs | ^^^^^^^^^^^ = note: `#[warn(clippy::unused_unit)]` implied by `#[warn(clippy::all)]`
unused import: `crate::ts::TsExportError`: src/export/export.rs#L1
warning: unused import: `crate::ts::TsExportError` --> src/export/export.rs:1:5 | 1 | use crate::ts::TsExportError; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
clippy
The following actions uses node12 which is deprecated and will be forced to run on node16: actions-rs/clippy-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/