From 9c2873320174e6d24143432ef98224c2c2634b88 Mon Sep 17 00:00:00 2001 From: Matus Valo Date: Sun, 3 Apr 2022 10:46:28 +0200 Subject: [PATCH 1/2] Added comparison-with-itself message example Co-authored-by: Vladyslav Krylasov --- doc/data/messages/c/comparison-with-itself/bad.py | 3 +++ doc/data/messages/c/comparison-with-itself/good.py | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 doc/data/messages/c/comparison-with-itself/bad.py create mode 100644 doc/data/messages/c/comparison-with-itself/good.py diff --git a/doc/data/messages/c/comparison-with-itself/bad.py b/doc/data/messages/c/comparison-with-itself/bad.py new file mode 100644 index 0000000000..f37531933e --- /dev/null +++ b/doc/data/messages/c/comparison-with-itself/bad.py @@ -0,0 +1,3 @@ +value = 5 +if value == value: # [comparison-with-itself] + pass diff --git a/doc/data/messages/c/comparison-with-itself/good.py b/doc/data/messages/c/comparison-with-itself/good.py new file mode 100644 index 0000000000..fdd1e7f319 --- /dev/null +++ b/doc/data/messages/c/comparison-with-itself/good.py @@ -0,0 +1,3 @@ +value = 5 +if value: + pass From a4d4fb6f44edecfa39345ee7a4364fb059f304d4 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 3 Apr 2022 17:24:18 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- doc/data/messages/c/comparison-with-itself/bad.py | 6 +++--- doc/data/messages/c/comparison-with-itself/good.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/data/messages/c/comparison-with-itself/bad.py b/doc/data/messages/c/comparison-with-itself/bad.py index f37531933e..77794bc5c9 100644 --- a/doc/data/messages/c/comparison-with-itself/bad.py +++ b/doc/data/messages/c/comparison-with-itself/bad.py @@ -1,3 +1,3 @@ -value = 5 -if value == value: # [comparison-with-itself] - pass +def is_an_orange(fruit): + an_orange = "orange" + return fruit == fruit # [comparison-with-itself] diff --git a/doc/data/messages/c/comparison-with-itself/good.py b/doc/data/messages/c/comparison-with-itself/good.py index fdd1e7f319..b2b4296502 100644 --- a/doc/data/messages/c/comparison-with-itself/good.py +++ b/doc/data/messages/c/comparison-with-itself/good.py @@ -1,3 +1,3 @@ -value = 5 -if value: - pass +def is_an_orange(fruit): + an_orange = "orange" + return an_orange == fruit