Code quality checker - or not??

Code quality checker - or not??

by Howard Miller -
Number of replies: 14
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I may have picked this up wrong, but I seem to recall a discussion that implied that the new plugins repository has some sort of automagic code quality checker?

Is this so? And if it is, can it be had separately to check one's code quality "offline"

Ta!
Average of ratings: -
In reply to Howard Miller

Re: Code quality checker - or not??

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I think you are conflating two different things:

1. When you upload a zip to the new plugins database, it does some basic sanity checking, like making sure version.php is there and looks plausible. This has caused much wailing and gnashing of teeth, particularly becaues the early versions of the checking weren't exactly right. This is now documented here: http://docs.moodle.org/dev/Plugin_validation

2. The codechecker plugin: https://github.com/moodlehq/moodle-local_codechecker. There is now also a similar tool for checking PHPdocs. See http://docs.moodle.org/dev/Coding_style#Useful_tools. Both of these tools can be downloaded to your  Moodle, and used 'offline'.

Average of ratings: Useful (3)
In reply to Tim Hunt

Re: Code quality checker - or not??

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Thanks Tim - I conflate a great deal I fear smile

I think I was picking up on the first one - I assumed from all the ranting that it was rather more sophisticated than it appears to be. I'll go and have a look at them both!
In reply to Tim Hunt

Re: Code quality checker - or not??

by Hubert Chathi -

And I would say that neither of those has as much to do with code quality as they do with standards and conventions.

In reply to Hubert Chathi

Re: Code quality checker - or not??

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Quite so.... the first person to write the former will be wealthy indeed big grin
In reply to Hubert Chathi

Re: Code quality checker - or not??

by Anne Krijger -

And I would say thatfollowing the standards and conventions improve the clarity and readability of code and as such have a huge impact on the quality smile

Anne.

Average of ratings: Useful (1)
In reply to Anne Krijger

Re: Code quality checker - or not??

by Hubert Chathi -

I will not deny that there is some correlation, and there are certainly some standards that are aimed at improving the quality, but I think it is debatable as to whether it makes a "huge" impact.  Clarity and readability is, of course, an important point, and by following standards, it at least makes it easier for others to spot bugs and improve code.

I'm of course not trying to downplay the work that people have put into the plugin checker and code checker, but wanted to point out that just because some code passes those checkers doesn't mean that it's good quality.

In reply to Hubert Chathi

Re: Code quality checker - or not??

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

My observation of developers is that there is a strong correlation between developers who can format their code to whatever coding style they are told to follow, and good developers.

I can't work out why this is, because following a coding style is trivial, while writing code that gets all the important design decision right is hard.

I have to say that this is a totally unscientific observation. Can anyone want to confirm or deny it from their own observation?

In reply to Tim Hunt

Re: Code quality checker - or not??

by Anne Krijger -

Hi Tim,

I would love to confirm or deny, if I understood what point it is you're making smile

Rule #1 of the code style guide "The Elements of Java Style" is;
Adhere to the style of the original.

As about 80% of the work I've done the last 25 odd years has been extending or maintaining existing code, I've been exposed to a various coding styles.

With time adhering to them has become a lot easier, because of automatic formatters and checkers build in the IDE I use (currently mostly Eclipse).
So even if a coding style is used that goes against my nature, for example placing the opening bracket { on a new line, or using inline if-statements, these days I don't even have to think about it; the IDE does most of the work for me.

I still can be caugth off guard every now and then though, when for example a rule says you should NOT use mixed case (Who came up with tha idea? smile).

So when you say there is a strong correlation, you say that in your experience good developers have no problem following styling rules, right?

I would concur that statement.
Although I've also found that even the best developers can disagree quite strongly on what good coding style is smile

Anne.

Average of ratings: Useful (1)
In reply to Anne Krijger

Re: Code quality checker - or not??

by Tomasz Muras -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators

I couldn't agree more with you Anne. Personally, I don't really care about the coding style - as long as there is some tool that does it for me automatically.

I used to argue about the best way of formatting the code but I guess I was just young... smile.

At the same time, I also appreciate the fact that there are some very good developers who will simply refuse to read the code unless it's formatted their way - I know few of them personally.

Tomek

In reply to Tim Hunt

Re: Code quality checker - or not??

by Hubert Chathi -

One possible reason is that good developers generally understand the value of following coding styles, and so are more likely to spend the time adhering to it.  Also, following coding styles is about pickiness (about one's own work), which I would say is a general sign that the person is interested in quality.  (Of course, these are all gross generalizations.)

In reply to Hubert Chathi

Re: Code quality checker - or not??

by Anne Krijger -

Hi Hubert,

You are right; it is still very well possible to write bad software, but as you said yourself; "makes it easier for others to spot bugs and improve code".

It'sa bit like PHP vs Java; you can write crap software with both, but PHP makes it easier to cut corners. That's what has gotten it its bad name as a tool for script kiddies.
We as professional developers know that you can also write high quality code using PHP, so it's not the tool to blame, it's the tool using it smile

Anne.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Code quality checker - or not??

by Michael Aherne -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

It's worth noting that the codechecker plugin can be used nicely inside Eclipse, if you're using that for development. Install the PHP CodeSniffer plugin, create a new "CodeSniffer standard" in the preferences page, and point it at the moodle directory inside the codechecker folder.

Average of ratings: Useful (3)
In reply to Michael Aherne

Re: Code quality checker - or not??

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ooh! That is a nice tip. We ought to add that to the readme file.

Acutally: https://github.com/moodlehq/moodle-local_codechecker/pull/3

Average of ratings: Useful (2)
In reply to Tim Hunt

Re: Code quality checker - or not??

by Michael Aherne -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hope it's useful! I can't take the full credit for this, though - I found the plugin but it was Michael Hughes who worked out how to configure it.