rspec/rules/S4825/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

98 lines
1.8 KiB
Plaintext

include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
``++httplib++`` module
----
import http.client.HTTPConnection
def send_request(url):
http.client.HTTPConnection(url) # Sensitive
----
``++request++`` library
----
import requests
def send_request(url, method):
requests.request(method, url) # Sensitive
requests.get(url) # Sensitive
requests.put(url) # Sensitive
requests.post(url) # Sensitive
requests.patch(url) # Sensitive
requests.delete(url) # Sensitive
requests.head(url) # Sensitive
requests.options(url) # Sensitive
----
Python 2 ``++urllib2++``
----
import urllib2
url = 'http://www.example.com/'
def open_url(url):
urllib2.urlopen(url) # Sensitive
req = urllib2.Request(url=url,
data=b'This is data')
urllib2.urlopen(req) # Sensitive
opener = urllib2.build_opener(urllib2.HTTPHandler)
opener.open(url) # Sensitive
----
Python 3 ``++urllib++`` module
----
import urllib.request
url = 'http://www.example.com/'
def open_url(url, proxy_handler, proxy_auth_handler, proxies):
urllib.request.urlopen(url) # Sensitive
req = urllib.request.Request(url=url,
data=b'This is data')
urllib.request.urlopen(req) # Sensitive
opener = urllib.request.build_opener(proxy_handler, proxy_auth_handler)
opener.open(url) # Sensitive
opener = urllib.request.FancyURLopener(proxies)
opener.open(url) # Sensitive
urllib.request.urlretrieve(url) # Sensitive
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]