diff --git a/rules/S107/rust/metadata.json b/rules/S107/rust/metadata.json new file mode 100644 index 0000000000..e55944fb22 --- /dev/null +++ b/rules/S107/rust/metadata.json @@ -0,0 +1,6 @@ +{ + "tags": [ + "brain-overload", + "clippy" + ] +} diff --git a/rules/S107/rust/noncompliant.adoc b/rules/S107/rust/noncompliant.adoc new file mode 100644 index 0000000000..5ad4929307 --- /dev/null +++ b/rules/S107/rust/noncompliant.adoc @@ -0,0 +1,6 @@ +[source,rust] +---- +fn set_coordinates(x1: i32, y1: i32, z1: i32, x2: i32, y2: i32, z2: i32) { // Noncompliant + // ... +} +---- diff --git a/rules/S107/rust/rule.adoc b/rules/S107/rust/rule.adoc new file mode 100644 index 0000000000..9d60da2652 --- /dev/null +++ b/rules/S107/rust/rule.adoc @@ -0,0 +1,27 @@ +:language: rust + +include::../rule.adoc[] + +== Resources + +=== Documentation + +* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments + +ifdef::env-github,rspecator-view[] + +''' +== Implementation Specification +(visible only on this page) + +include::../message.adoc[] + +include::../parameters.adoc[] + +''' +== Comments And Links +(visible only on this page) + +include::../comments-and-links.adoc[] + +endif::env-github,rspecator-view[] diff --git a/rules/S107/rust/split-example.adoc b/rules/S107/rust/split-example.adoc new file mode 100644 index 0000000000..d4f5d7f8d5 --- /dev/null +++ b/rules/S107/rust/split-example.adoc @@ -0,0 +1,11 @@ +[source,rust] +---- +// Each function does a part of what the original setCoordinates function was doing, so confusion risks are lower +fn set_origin(x: i32, y: i32, z: i32) { + // ... +} + +fn set_size(width: i32, height: i32, depth: i32) { + // ... +} +---- diff --git a/rules/S107/rust/struct-example.adoc b/rules/S107/rust/struct-example.adoc new file mode 100644 index 0000000000..a4b18690f7 --- /dev/null +++ b/rules/S107/rust/struct-example.adoc @@ -0,0 +1,17 @@ +[source,rust] +---- +struct Point { + x: i32, + y: i32, +} + +impl Point { + fn new(x: i32, y: i32) -> Point { + Point { x, y } + } +} + +fn set_coordinates(p1: &mut Point, p2: &Point) { + // ... +} +----