rspec/rules/S107/vbnet/rule.adoc
Fred Tingaud 51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
2023-06-22 10:38:01 +02:00

74 lines
1.6 KiB
Plaintext

== Why is this an issue?
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the procedure is doing too many things.
=== Noncompliant code example
With a maximum number of 3 parameters:
[source,vbnet]
----
Public Sub Foo(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As Integer, ByVal p4 As Integer) ' Noncompliant
' ...
End Sub
Public Function Bar(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As Integer, ByVal p4 As Integer) ' Noncompliant
' ...
End Function
----
=== Compliant solution
[source,vbnet]
----
Public Sub Foo(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As Integer)
' ...
End Sub
Public Function Bar(ByVal p1 As Integer, ByVal p2 As Integer, ByVal p3 As Integer)
' ...
End Function
----
=== Exceptions
[source,vbnet]
----
Public Class BaseClass
Public Sub New(Param1 As Integer)
' ...
End Sub
End Class
Public Class DerivedClass
Inherits BaseClass
Public Sub New(Param1 As Integer, Param2 As Integer, Param3 As Integer, Param4 As Integer, Param5 As Long)
MyBase.New(Param1) ' Compliant, the parameters intended for the base class constructor do not count in the sum of the parameter list.
' ...
End Sub
End Class
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
[Constructor|Function|Sub|Delegate|Lambda] has {0} parameters, which is greater than the {1} authorized.
include::../parameters.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]