ShinyCMS code quality: an illustrated history

Posted by Denny at 11:11 on Sat, 24 Apr 2021

Following on from my post last night about the change in my Ruby Critic scores after I tweaked the config for flay, I thought I'd grab a copy of the code as it was at each of the releases I've tagged so far on GitHub, and get a screenshot of the Ruby Critic overview page for each - to see how the scores have shifted over time.

You can see where I started using Ruby Critic - between the 21.01 and 21.03 releases I break up the plugin generator code, which was the worst quality code in the project (not my code, I might add; it's a stripped down version of the Rails engine generator!) by such a wide margin that it was forcing everything else into the bottom quarter of the charts. Once I got that split up a bit, the rest of the files were able to spread out more usefully on the resulting zoomed-in scale :)

The screenshots below start with the most recent two that were in the previous post, and then head backwards in time. My milestone releases are usually on the 1st of the month, or at least in that general vicinity, so these are fairly evenly-spaced monthly snapshots for the last seven months. I've only pulled the tagged releases for now, which started in October 2020. That was one year after the project launched, and I must admit I am very curious to see how the story develops right from day one now... so I might go back and generate monthly screenshots for that first year at some point soon.

Code Quality vs Cheat Codes

Posted by Denny at 22:51 on Fri, 23 Apr 2021

Ruby Critic summary chartI've been using Ruby Critic to track code quality metrics for a while now (both in work projects and personal projects, although I tend to get more time for fixing the things it highlights in the personal ones). One thing that has been annoying me in this particular project is that, between the 'convention over configuration' approach of Rails, and the 'built up from common roles and patterns' approach I've tried to take with the ShinyCMS plugins, there are a few areas of the code that get a bad score from flay, the tool used by Ruby Critic to look for duplicate code.

The reason for a duplicate code scan, is that often duplicate code is a prime candidate for being factored out into a common method or similar. But in the case of ShinyCMS, most of what it's detecting is the way that, for example, a skinny Rails controller tends to have the same few RESTful actions, doing the same checks with the same consequences, and really only the names of the constants and variables tend to change sometimes. I could factor that out, but it would make those controllers much less conventional, and hence harder for other people to work on - pretty much the opposite of what I want to achieve!

So, I finally got around to looking at the flay documentation a few days ago, and then I added a `.flayignore` file to skip checking controllers and policies for duplication. This had a quite noticeable effect on the lower-scoring files in my Ruby Critic summary - the D and F grades - in fact it got rid of every single one of them.

April 2021: The 'Respecting Boundaries' release

Posted by Denny at 14:30 on Thu, 08 Apr 2021

Main addition (and cause of some fairly major code shuffling) in this release is Packwerk, to enforce plugin boundaries.

Also added routes partials, bullet (N+1 query detection), CodeClimate coverage reporting, and the Items extension for Pagy.

Plus lots of improvements to base controllers and mailers (now in the core plugin's `app/public` area), and moved Rails Email Preview engine, rubocop config, and ShinyCMS rake tasks, from main_app into the core plugin.

March 2021: The 'Yo dawg I herd u liek CMS' release

Posted by Denny at 08:49 on Mon, 01 Mar 2021

Headline for this release: I moved almost all the code that was still in main_app, into a plugin! :-o

I also wrote a lot more code to support the Plugins 'infrastructure' or framework or whatever you'd call it I used the Persistent Diamond immutable data structures to underpin the Plugin subsystem; so far so good, so probably more of that in future.

New plugin! ShinySEO can generate sitemaps for Googe et al (although it's not automated yet)

February 2021: The 'quiet after the storm' release

Posted by Denny at 19:55 on Mon, 01 Feb 2021

A quiet month, after last month's big bang of Ruby + Rails upgrades!

Bug fixes include tags on hidden content being hidden now, a fix to user profile instantiation in dev that stops the User.profile relation vanishing under stress, and more robust handling of attempts to hit non-existent non-HTML resources (usually by malware).

Various bits of work on code quality - in particular, refactoring around the User model, and moving admin 'quick search' implementation details from controllers to models. Also, properly adding Ruby Critic, and continuing to nibble away at the things it highlights.

Happy New Year, Happy New Rails, Happy New Ruby! 🎉

Posted by Denny at 00:11 on Fri, 01 Jan 2021

A couple of fairly significant bumps in the dependency chain last month, with Rails going from 6.0 to 6.1, and Ruby from 2.7 to 3.0 - between them this entire release probably counts as a breaking change. Enjoy! 

Other notable updates include a change of pagination gem (goodbye Kaminari, hello Pagy!), the removal of Travis CI (the new owners do not seem keen on open source projects), the addition of a few more code quality tools (rubocop-rspec, rails_best_practices, rubycritic, and TypoCI), and some more work on moving all of the supporting files for themes into the /themes directory - this time the JavaScript bits.

More details in the release notes, as ever.

LRUG talk: "Patches Welcome!"

Posted by Denny at 22:00 on Mon, 09 Nov 2020

I gave a talk at LRUG tonight. The title I went with was "Patches Welcome!", although a more prosaic title could have been "Why I do open source software development". It covered how I got started in open source and what I learned from that (professionally and philosophically), as well as what I'm currently working on (ShinyCMS, mostly!) and how I can use my own projects to help other people.

LRUG recorded the talk and have shared the video:

Sidekiq Status

Posted by Denny at 19:46 on Wed, 04 Nov 2020

Sidekiq Status web dashboardI've just added the Sidekiq::Status gem (with appropriate config), and hooked it into the jobs that rebuild the blog/news feeds and send newsletter emails.

If you have longer-running jobs (sending to a big mailing list, for instance) then while those jobs are running you'll be able to use the new 'Statuses' section of the Sidekiq web dashboard to see details of what Sidekiq and ActiveJob are doing 'mid flight'.

Spam, spam, spam, egg, chips, and spam

Posted by Denny at 18:55 on Sun, 01 Nov 2020

I recently enabled the contact form on this site, but I soon realised that I had missed out an important feature when I wrote the ShinyForms plugin. A large number of spambots were kind enough to bring this mistake to my attention, and that's why today's merged PR adds reCAPTCHA and Akismet protection to ShinyForm submissions.

Update, two days later: Apparently I rushed that feature a tiny bit, in my haste to defend my inbox. Here's a PR that fixes form recaptcha, and adds form mailer tests.

Paginate All The Things

Posted by Denny at 01:04 on Thu, 22 Oct 2020

In a tidal wave of copypasta, I just added admin pagination and search routes for All The Things - mostly because I tripped over the docs for route concerns while I was looking for something else, thought they sounded good, and wanted to try them out :)

Newer