DEV Community

loading...
Cover image for Unconditional: an action to promote polymorphism

Unconditional: an action to promote polymorphism

gabrielbarker profile image gabrielbarker ・1 min read

badge

Sometimes it feels easier to add an if statement and handle a 'special case' than to stop that case from being special in the first place. That's where unconditional comes in...

My Workflow

Unconditional is a GitHub action to determine the concentration and distribution of conditional logic in your code. In OOP it is usually considered a good idea to reduce conditional logic wherever possible, and, in instances where they are necessary in a program, push your conditional logic to the front edge of your project. This reduces complexity and makes use of polymorphism.

It can be hard to keep track of conditionals, and once one is introduced, we often need to add more to compensate.

Unconditional parses the repo, searching designated files for if statements. A report is then generated to tell you how many conditionals exist in your code, and how they are distributed.

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

GitHub logo gabrielbarker / unconditional

A GitHub action to determine the concentration and distribution of conditional logic in your code

Unconditional

A GitHub action to determine the concentration and distribution of conditional logic in your code

OverviewHow To UseFor ReferenceBackgroundLicense


Insist on simplicity. Resist special cases. Listen to conditionals. Identify underlying concepts. And search for the abstractions that let you treat everything the same.

-- Sandi Metz, Make Everything The Same

Overview

Unconditional is a workflow that locates if statements in your code. You can set limits on how many conditionals to allow in a given file, and restrict where Unconditional should look for them. This helps to reduce complexity and promote polymorphism.

How To Use

Unconditional accepts 4 input variables:

  • The paths that should be included in the search, given as glob patterns seperated by commas
  • The paths that should be excluded from the search, given as glob patterns seperated by commas
  • The paths that should be considered an acceptable layer…

Additional Resources / Info

Discussion (0)

Forem Open with the Forem app