Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support linting of enum and sibling conventions #1061

Open
dkolbly opened this issue Apr 24, 2024 · 0 comments
Open

Support linting of enum and sibling conventions #1061

dkolbly opened this issue Apr 24, 2024 · 0 comments

Comments

@dkolbly
Copy link
Contributor

dkolbly commented Apr 24, 2024

There are some conventions that are not necessary to build a well-formed schema, but yet are commonplace in OCSF and have considerable utility.

We should support linting (convention validation) of those things.

The two I am aware of are:

  • naming conventions for sibling fields where the original field ends in _id or _uid
  • the presence of a 0 enumerand to denote Unknown and a 99 enumerand to denote Other

I have sketched out some ideas over in my fork for what this might look like. I took a TDD (Test Driven Development) approach by first implementing the linting rules and then adding lint control options to address the failures.

The basic proposal is to add a lint property (currently only on attributes) that can be a list of strings that configure different lint controls, initially just:

  • no-enum-convention to denote an attribute that does not follow the 0/99 enumeration convention, and
  • no-sibling-convention to denote an attribute that does not follow the _id/_uid sibling attribute naming convention.

I added lint control options where I could see they made sense, but one occurrence remained for the former that might be an actual bug. To discuss. It is this one:
image

Here is what I imagine a lint property might look like, as applied to the historical activity_id which by convention should have a sibling of activity but doesn't:

    "activity_id": {
      "caption": "Activity ID",
      "description": "The normalized identifier of the activity that triggered the event.",
      "enum": {
        "99": {
          "caption": "Other",
          "description": "The event activity is not mapped. See the <code>activity_name</code> attribute, which contains a data source specific value."
        },
        "0": {
          "caption": "Unknown",
          "description": "The event activity is unknown."
        }
      },
      "sibling": "activity_name",
      "lint": ["no-sibling-convention"],
      "type": "integer_t"
    },

corresponding linter support in my validator: https://bitbucket.org/dkolbly/osf-meta/pull-requests/7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants