rspec/rules/S1192/vbnet/rule.adoc

71 lines
1.2 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-01-21 04:09:13 +00:00
include::../description.adoc[]
=== Noncompliant code example
2021-01-21 04:09:13 +00:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2021-01-21 04:09:13 +00:00
----
Public Class Foo
2021-01-23 04:07:47 +00:00
Private Name As String = "foobar" ' Noncompliant
2021-01-21 04:09:13 +00:00
Public ReadOnly Property DefaultName As String = "foobar" ' Noncompliant
2021-01-23 04:07:47 +00:00
Public Sub New(Optional Value As String = "foobar") ' Noncompliant
2021-01-21 04:09:13 +00:00
2021-01-23 04:07:47 +00:00
Dim Something = If(Value, "foobar") ' Noncompliant
2021-01-21 04:09:13 +00:00
End Sub
End Class
----
=== Compliant solution
2021-01-21 04:09:13 +00:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2021-01-21 04:09:13 +00:00
----
Public Class Foo
Private Const Foobar As String = "foobar"
2021-01-23 04:07:47 +00:00
Private Name As String = Foobar
2021-01-21 04:09:13 +00:00
Public ReadOnly Property DefaultName As String = Foobar
2021-01-23 04:07:47 +00:00
Public Sub New(Optional Value As String = Foobar)
2021-01-21 04:09:13 +00:00
2021-01-23 04:07:47 +00:00
Dim Something = If(Value, Foobar)
2021-01-21 04:09:13 +00:00
End Sub
End Class
----
=== Exceptions
2021-01-21 04:09:13 +00:00
The following are ignored:
* literals with fewer than 5 characters
* literals matching one of the parameter names
* literals used in attributes
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::../parameters.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]