← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/turnip:woke into turnip:master

 

Colin Watson has proposed merging ~cjwatson/turnip:woke into turnip:master.

Commit message:
Apply inclusive naming via the woke pre-commit hook

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/turnip/+git/turnip/+merge/419292

I ignored a couple of issues that arise from class names in Twisted.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/turnip:woke into turnip:master.
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ce0c054..da6c77d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -18,3 +18,7 @@ repos:
     rev: 5.10.1
     hooks:
     -   id: isort
+-   repo: https://github.com/get-woke/woke
+    rev: v0.17.0
+    hooks:
+    -   id: woke-from-source
diff --git a/.woke.yaml b/.woke.yaml
new file mode 100644
index 0000000..010ccff
--- /dev/null
+++ b/.woke.yaml
@@ -0,0 +1,221 @@
+
+# Based on Canonical's Guidelines
+# https://docs.google.com/document/d/1mJUa1VJHOMWa723dmKmNjSKGW-nlBv9xktzGZZwacVo/edit#heading=h.5efudb237qdb
+rules:
+  - name: whitelist
+    terms:
+      - whitelist
+      - white-list
+      - whitelisted
+      - white-listed
+    alternatives:
+      - allowlist
+      - inclusion list
+    severity: warning
+    note: "The underlying assumption of the whitelist/blacklist metaphor is that white = good and black = bad. Because colors in and of themselves have no predetermined meaning, any meaning we assign to them is cultural: for example, the color red in many Southeast Asian countries is lucky, and is often associated with events like marriages, whereas the color white carries the same connotations in many European countries. In the case of whitelist/blacklist, the terms originate in the publishing industry – one dominated by the USA and England, two countries which participated in slavery and which grapple with their racist legacies to this day."
+
+  - name: blacklist
+    terms:
+      - blacklist
+      - black-list
+      - blacklisted
+      - black-listed
+    alternatives:
+      - denylist
+      - blocklist
+      - exclusion list
+    severity: warning
+    note: "The underlying assumption of the whitelist/blacklist metaphor is that white = good and black = bad. Because colors in and of themselves have no predetermined meaning, any meaning we assign to them is cultural: for example, the color red in many Southeast Asian countries is lucky, and is often associated with events like marriages, whereas the color white carries the same connotations in many European countries. In the case of whitelist/blacklist, the terms originate in the publishing industry – one dominated by the USA and England, two countries which participated in slavery and which grapple with their racist legacies to this day."
+
+  - name: master-slave
+    terms:
+      - master-slave
+      - master/slave
+    alternatives:
+      - leader/follower
+      - main/replica
+      - primary/replica
+      - primary/standby
+      - primary/secondary
+
+  - name: slave
+    terms:
+      - slave
+    alternatives:
+      - follower
+      - replica
+      - standby
+
+  - name: grandfathered
+    terms:
+      - grandfathered
+    alternatives:
+      - legacy status
+      - legacied
+      - exempted
+      - carried
+      - brought forward
+      - rolled over
+
+  - name: man-hours
+    terms:
+      - man hours
+      - man-hours
+    alternatives:
+      - person hours
+      - engineer hours
+
+  - name: sanity
+    terms:
+      - sanity
+    alternatives:
+      - confidence
+      - quick check
+      - coherence check
+
+  - name: dummy
+    terms:
+      - dummy
+    alternatives:
+      - placeholder
+      - sample
+
+  - name: guys
+    terms:
+      - guys
+    alternatives:
+      - folks
+      - people
+      - you all
+      - y'all
+      - yinz
+
+  - name: whitebox
+    terms:
+      - white-box
+      - whitebox
+      - white box
+    alternatives:
+      - open-box
+
+  - name: blackbox
+    terms:
+      - black-box
+      - blackbox
+      - black box
+    alternatives:
+      - closed-box
+
+  - name: blackhat
+    terms:
+      - blackhat
+      - black-hat
+      - black hat
+    alternatives:
+      - attacker
+      - malicious actor
+
+  - name: whitehat
+    terms:
+      - whitehat
+      - white-hat
+      - white hat
+    alternatives:
+      - researcher
+      - security specialist
+
+  - name: illegal characters
+    terms:
+      - illegal characters
+    alternatives:
+      - invalid characters
+      - unsupported characters
+      - special characters
+
+  - name: native feature
+    terms:
+      - native feature
+    alternatives:
+      - core feature
+      - built-in feature
+
+  - name: chairman/foreman
+    terms:
+      - chairman
+      - foreman
+    alternatives:
+      - chair
+      - foreperson
+
+  - name: man in the middle
+    terms:
+      - man in the middle
+      - man-in-the-middle
+    alternatives:
+      - machine-in-the-middle
+      - person-in-the-middle
+      - system-in-the-middle
+      - intermediary attack
+
+  - name: middleman
+    terms:
+      - middleman
+    alternatives:
+      - middleperson
+      - intermediary
+
+  - name: manned
+    terms:
+      - manned
+    alternatives:
+      - crewed
+      - staffed
+      - monitored
+      - human operated
+
+  - name: mom test / girlfriend test
+    terms:
+      - mom test
+      - girlfriend test
+    alternatives:
+      - user test
+      - user friendly
+
+  - name: crazy
+    terms:
+      - crazy
+    alternatives:
+      - baffling
+      - unexplained
+      - errant
+
+  - name: cripples
+    terms:
+      - cripples
+    alternatives:
+      - slows down
+      - hinders
+      - obstructs
+
+  - name: crippling
+    terms:
+      - crippling
+    alternatives:
+      - attenuating
+      - incapacitating
+
+  - name: stonith/stomith
+    terms:
+      - stonith
+      - stomith
+    alternatives:
+      - fence failed nodes
+      - machines
+
+  - name: demilitarized zone
+    terms:
+      - demilitarized zone
+      - dmz
+    alternatives:
+      - perimeter network
+      - passthrough network
diff --git a/.wokeignore b/.wokeignore
new file mode 100644
index 0000000..195408d
--- /dev/null
+++ b/.wokeignore
@@ -0,0 +1,2 @@
+# Matches rules by accident.
+turnip/pack/tests/data/ssh-key
diff --git a/turnip/pack/tests/test_git.py b/turnip/pack/tests/test_git.py
index 7d8fba7..feec902 100644
--- a/turnip/pack/tests/test_git.py
+++ b/turnip/pack/tests/test_git.py
@@ -43,7 +43,7 @@ from turnip.pack.tests.test_helpers import MockStatsd
 from turnip.pack.tests.test_hooks import MockHookRPCHandler
 
 
-class DummyPackServerProtocol(git.PackServerProtocol):
+class FakePackServerProtocol(git.PackServerProtocol):
 
     test_request = None
 
@@ -58,7 +58,7 @@ class TestPackServerProtocol(TestCase):
 
     def setUp(self):
         super().setUp()
-        self.proto = DummyPackServerProtocol()
+        self.proto = FakePackServerProtocol()
         self.transport = testing.StringTransportWithDisconnection()
         self.transport.protocol = self.proto
         self.proto.makeConnection(self.transport)
@@ -116,7 +116,7 @@ class TestPackServerProtocol(TestCase):
         self.assertKilledWith(b'Bad request: flush-pkt instead')
 
 
-class DummyPackBackendProtocol(git.PackBackendProtocol):
+class FakePackBackendProtocol(git.PackBackendProtocol):
 
     test_process = None
 
@@ -187,7 +187,7 @@ class TestPackBackendProtocol(TestCase):
         self.factory = git.PackBackendFactory(
             self.root, self.hookrpc_handler,
             self.hookrpc_sock, self.statsd_client)
-        self.proto = DummyPackBackendProtocol()
+        self.proto = FakePackBackendProtocol()
         self.proto.factory = self.factory
         self.transport = testing.StringTransportWithDisconnection()
         self.transport.protocol = self.proto
@@ -356,7 +356,7 @@ class TestPackBackendProtocol(TestCase):
         self.assertKilledWith(b'Symbolic ref target may not contain " "')
 
 
-class DummyPackBackendFactory(git.PackBackendFactory):
+class FakePackBackendFactory(git.PackBackendFactory):
 
     test_protocol = None
 
@@ -382,9 +382,9 @@ class TestPackVirtServerProtocol(TestCase):
         self.root = self.useFixture(TempDir()).path
         self.hookrpc_handler = MockHookRPCHandler()
         self.hookrpc_sock = os.path.join(self.root, 'hookrpc_sock')
-        self.backend_factory = DummyPackBackendFactory(
+        self.backend_factory = FakePackBackendFactory(
             self.root, self.hookrpc_handler, self.hookrpc_sock)
-        self.backend_factory.protocol = DummyPackBackendProtocol
+        self.backend_factory.protocol = FakePackBackendProtocol
         self.backend_listener = default_reactor.listenTCP(
             0, self.backend_factory)
         self.backend_port = self.backend_listener.getHost().port
diff --git a/turnip/pack/tests/test_helpers.py b/turnip/pack/tests/test_helpers.py
index d652bf8..08f9841 100644
--- a/turnip/pack/tests/test_helpers.py
+++ b/turnip/pack/tests/test_helpers.py
@@ -332,7 +332,7 @@ class TestCapabilityAdvertisement(TestCase):
         our git command advertises."""
         root = tempfile.mkdtemp(prefix=b'turnip-test-root-')
         self.addCleanup(shutil.rmtree, root, ignore_errors=True)
-        # Create a dummy repository
+        # Create an empty repository
         subprocess.call(['git', 'init', root])
 
         git_version = subprocess.check_output(['git', '--version'])
diff --git a/turnip/pack/tests/test_hookrpc.py b/turnip/pack/tests/test_hookrpc.py
index 4270764..9e7bafa 100644
--- a/turnip/pack/tests/test_hookrpc.py
+++ b/turnip/pack/tests/test_hookrpc.py
@@ -42,7 +42,7 @@ from turnip.pack import hookrpc
 from turnip.pack.tests.fake_servers import FakeVirtInfoService
 
 
-class DummyJSONNetstringProtocol(hookrpc.JSONNetstringProtocol):
+class FakeJSONNetstringProtocol(hookrpc.JSONNetstringProtocol):
 
     response_deferred = None
 
@@ -71,7 +71,7 @@ class TestJSONNetStringProtocol(TestCase):
 
     def setUp(self):
         super().setUp()
-        self.proto = DummyJSONNetstringProtocol()
+        self.proto = FakeJSONNetstringProtocol()
         self.transport = testing.StringTransportWithDisconnection()
         self.transport.protocol = self.proto
         self.proto.makeConnection(self.transport)
diff --git a/turnip/pack/tests/test_http.py b/turnip/pack/tests/test_http.py
index 2b01f62..735e28c 100644
--- a/turnip/pack/tests/test_http.py
+++ b/turnip/pack/tests/test_http.py
@@ -41,7 +41,8 @@ from turnip.pack.http import (
 from turnip.pack.tests.fake_servers import FakeVirtInfoService
 
 
-class LessDummyRequest(requesthelper.DummyRequest):
+# wokeignore:rule=dummy
+class LessFakeRequest(requesthelper.DummyRequest):
 
     startedWriting = 0
 
@@ -59,6 +60,7 @@ class LessDummyRequest(requesthelper.DummyRequest):
         super().write(data)
 
     def registerProducer(self, prod, s):
+        # wokeignore:rule=dummy
         # Avoid DummyRequest.registerProducer calling resumeProducing
         # forever, never giving the reactor a chance to run.
         if not s:
@@ -77,12 +79,12 @@ class LessDummyRequest(requesthelper.DummyRequest):
         return self.cookies.get(name)
 
 
-class AuthenticatedLessDummyRequest(LessDummyRequest):
+class AuthenticatedLessFakeRequest(LessFakeRequest):
     def getUser(self):
-        return 'dummy-username'
+        return 'fake-username'
 
     def getPassword(self):
-        return 'dummy-password'
+        return 'fake-password'
 
 
 def render_resource(resource, request):
@@ -191,7 +193,7 @@ class TestSmartHTTPRefsResource(ErrorTestMixin, TestCase):
     def setUp(self):
         super().setUp()
         self.root = FakeRoot()
-        self.request = LessDummyRequest([b''])
+        self.request = LessFakeRequest([b''])
         self.request.method = b'GET'
 
     def makeResource(self, service):
@@ -234,7 +236,7 @@ class TestSmartHTTPRefsResource(ErrorTestMixin, TestCase):
 
     @defer.inlineCallbacks
     def test_good_authenticated(self):
-        self.request = AuthenticatedLessDummyRequest([b''])
+        self.request = AuthenticatedLessFakeRequest([b''])
         yield self.performRequest(
             helpers.encode_packet(b'I am git protocol data.') +
             b'And I am raw, since we got a good packet to start with.')
@@ -277,7 +279,7 @@ class TestSmartHTTPCommandResource(ErrorTestMixin, TestCase):
     def setUp(self):
         super().setUp()
         self.root = FakeRoot()
-        self.request = LessDummyRequest([''])
+        self.request = LessFakeRequest([''])
         self.request.method = b'POST'
         self.request.requestHeaders.addRawHeader(
             b'Content-Type', b'application/x-git-upload-pack-request')
@@ -328,7 +330,7 @@ class TestHTTPAuthLoginResource(TestCase):
             'nickname': 'pappacena', 'country': 'BR'
         }
 
-        request = LessDummyRequest([''])
+        request = LessFakeRequest([''])
         request.method = b'GET'
         request.path = b'/example'
         request.args = {
@@ -350,7 +352,7 @@ class TestHTTPAuthLoginResource(TestCase):
 
     def test_getSession(self):
         response = mock.Mock()
-        request = LessDummyRequest([''])
+        request = LessFakeRequest([''])
         request.method = b'GET'
         request.path = b'/example'
         request.args = {
@@ -389,7 +391,7 @@ class TestHTTPAuthRootResource(TestCase):
     def test__beginLogin(self):
         root = self.root
         root.openid_provider_root = 'https://testopenid.test/'
-        request = LessDummyRequest([''])
+        request = LessFakeRequest([''])
         request.method = b'GET'
         request.path = b'/example'
         session = {}
@@ -410,7 +412,7 @@ class TestHTTPAuthRootResource(TestCase):
 
     def test_translatePath_timeout(self):
         root = self.root
-        request = LessDummyRequest([''])
+        request = LessFakeRequest([''])
         request.method = b'GET'
         request.path = b'/example'
         d = render_resource(http.HTTPAuthRootResource(root), request)
@@ -424,12 +426,12 @@ class TestHTTPAuthRootResource(TestCase):
     @defer.inlineCallbacks
     def test_render_root_repo(self):
         root = self.root
-        request = LessDummyRequest([''])
+        request = LessFakeRequest([''])
         store.init_repo(os.path.join(
             root.repo_store, self.virtinfo.getInternalPath('/example')))
         request.method = b'GET'
         request.path = b'/example'
-        request.uri = b'http://dummy/example'
+        request.uri = b'http://fake.example.com/example'
         yield render_resource(http.HTTPAuthRootResource(root), request)
         response_content = b''.join(request.written)
         self.assertIn(b"Repository seems to be empty", response_content)
@@ -437,15 +439,15 @@ class TestHTTPAuthRootResource(TestCase):
 
 class TestProtocolVersion(TestCase):
     def test_get_protocol_version_from_request_default_zero(self):
-        request = LessDummyRequest("/foo")
+        request = LessFakeRequest("/foo")
         self.assertEqual(b'0', get_protocol_version_from_request(request))
 
     def test_get_protocol_version_from_request_fallback_to_zero(self):
-        request = LessDummyRequest("/foo")
+        request = LessFakeRequest("/foo")
         request.requestHeaders.setRawHeaders('git-protocol', [b'invalid'])
         self.assertEqual(b'0', get_protocol_version_from_request(request))
 
     def test_get_protocol_version_from_request(self):
-        request = LessDummyRequest("/foo")
+        request = LessFakeRequest("/foo")
         request.requestHeaders.setRawHeaders('git-protocol', [b'version=2'])
         self.assertEqual(b'2', get_protocol_version_from_request(request))