OpenLightingProject / OpenLightingProject/open-fixture-library

Extract plugin helpers into a lib script

Open
#989 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component-plugin refactoring
Dominant language
JSON
Stars
258
Forks
102
Avg merge
11h 52m
Merged PRs (30d)
53

Description

In both e:cue and QLC+ 4.11.2 (or 4.12.1 after #978 is merged) import plugins, there are some helper functions that try to guess capability type and type-dependent properties from the capability name. We should make them as general as possible and extract them to a lib script to reduce code duplication and improve maintainability.

Keep in mind that changes of this lib script should then also trigger GitHub tests (see also #988).

In particular, the getSpeedGuessedComment function needs to be extracted and cleaned up. Copied from https://github.com/OpenLightingProject/open-fixture-library/pull/978#discussion_r310933525 and https://github.com/OpenLightingProject/open-fixture-library/pull/978#discussion_r311223634:

This function sets some properties, but to ensure a consistent property order, a lot of extra logic is needed from where it is called. Furthermore, there are some (unexpected) side effect it does, for example setting the capability type.

It may be worth refactoring this to return an object { type, speedStart, speedEnd, comment } where any of the properties may be an empty string. Then set the cap data like so:

const { type, speedStart, speedEnd, comment } = guessSpeedData(capabilityName, cap);
cap.type = type || cap.type;
cap.effectName = comment;
if (speedStart) {
  cap.shakeSpeedStart = speedStart;
  cap.shakeSpeedEnd = speedEnd;
}

[Regarding the regular expression:] Is there a way to beat this beast of RegExp? Maybe use some RegExp.exec instead of a single replace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the e:cue and QLC+ 4.11.2 import plugins and locate getSpeedGuessedComment plus the other capability-guessing helpers. Review the linked #978 discussions and #988 for the expected refactoring and GitHub test behavior. Done means the helpers are shared through a lib script, the returned capability data is applied consistently, and changes to that script trigger the tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.