rspec/rules/S4784/python/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

87 lines
2.0 KiB
Plaintext

include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
Django
----
from django.core.validators import RegexValidator
from django.urls import re_path
RegexValidator('(a*)*b') # Sensitive
def define_http_endpoint(view):
re_path(r'^(a*)*b/$', view) # Sensitive
----
``++re++`` module
----
import re
from re import compile, match, search, fullmatch, split, findall, finditer, sub, subn
input = 'input string'
replacement = 'replacement'
re.compile('(a*)*b') # Sensitive
re.match('(a*)*b', input) # Sensitive
re.search('(a*)*b', input) # Sensitive
re.fullmatch('(a*)*b', input) # Sensitive
re.split('(a*)*b', input) # Sensitive
re.findall('(a*)*b', input) # Sensitive
re.finditer('(a*)*b',input) # Sensitive
re.sub('(a*)*b', replacement, input) # Sensitive
re.subn('(a*)*b', replacement, input) # Sensitive
----
``++regex++`` module
----
import regex
from regex import compile, match, search, fullmatch, split, findall, finditer, sub, subn, subf, subfn, splititer
input = 'input string'
replacement = 'replacement'
regex.subf('(a*)*b', replacement, input) # Sensitive
regex.subfn('(a*)*b', replacement, input) # Sensitive
regex.splititer('(a*)*b', input) # Sensitive
regex.compile('(a*)*b') # Sensitive
regex.match('(a*)*b', input) # Sensitive
regex.search('(a*)*b', input) # Sensitive
regex.fullmatch('(a*)*b', input) # Sensitive
regex.split('(a*)*b', input) # Sensitive
regex.findall('(a*)*b', input) # Sensitive
regex.finditer('(a*)*b',input) # Sensitive
regex.sub('(a*)*b', replacement, input) # Sensitive
regex.subn('(a*)*b', replacement, input) # Sensitive
----
include::../exceptions.adoc[]
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]