From: Felipe Contreras <felipe.contreras@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, "Martin Ågren" <martin.agren@gmail.com>
Subject: Re: [PATCH 0/2] Trivial cleanups
Date: Tue, 15 Jun 2021 03:22:05 -0500 [thread overview]
Message-ID: <60c8632d60027_e633208db@natae.notmuch> (raw)
In-Reply-To: <xmqqbl87zyra.fsf@gitster.g>
Junio C Hamano wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
> > These perfeclty good patches from 2014 weren't picked with no good
> > reason.
>
> These are safe no-op changes, but that does not mean they are good
> patches.
They are not good patches because they are no-op, they are good changes
because they correct the flow of the code to match the flow in which
most people think.
18 is younger than Mary
is not a sentence most people would agree make sense.
> It goes against Documentation/CodingGuidelines to bring it
> back again now, which is a good enough reason not to look at them.
These are not style issues. Refactoring code to make it easier to
understand goes beyond style.
Refactoring this:
static int is_same_remote(struct remote *remote)
{
struct remote *fetch_remote = remote_get(NULL);
return (!fetch_remote || fetch_remote == remote);
}
int same_remote = is_same_remote(remote);
To this:
int same_remote = remote == remote_get(NULL);
Is more than just style.
But suit yourself. Sooner or later somebody is going to fix these
glaring mistakes. And they are mistakes [1].
Yoda conditions are widely criticized for compromising readability by
increasing the cognitive load of reading the code.
Cheers.
[1] https://en.wikipedia.org/wiki/Yoda_conditions#Criticism
--
Felipe Contreras
prev parent reply other threads:[~2021-06-15 8:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-13 6:37 [PATCH 0/2] Trivial cleanups Felipe Contreras
2021-06-13 6:37 ` [PATCH 1/2] config: avoid yoda conditions Felipe Contreras
2021-06-13 6:37 ` [PATCH 2/2] add: avoid yoda condition Felipe Contreras
2021-06-15 1:45 ` [PATCH 0/2] Trivial cleanups Junio C Hamano
2021-06-15 8:22 ` Felipe Contreras [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60c8632d60027_e633208db@natae.notmuch \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=martin.agren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).