Skip to content

move QA directives into ebuilds and eclasses #763

@ferringb

Description

@ferringb

This relates to #762; in that, one must hardcode certain eclasses into pkgcheck. The source being examined, it already knows what it's doing and where it may cause QA issues. It should inform pkgcheck of where it's knowingly doing something naughty, or tell pkgcheck how it needs to be checked.

The rough idea is to move all qa directives- the hardcoded eclass awareness or ebuild awareness- down into the source, and since we can extract it via tree-sitter-bash, do so.

I'm assuming part of the "only run this on gentoo repos" is restricting standards enforcement. Gentoo-x86 has a higher enforcement, specifically. To address this would require a repository level directive, which isn't bash- another file in the repo. Do we already have this?

What I'm proposing for the bash syntax is thus:

ebuilds:

__QA_EBUILD_DIRECTIVE__=( check1:enable, check2:disable, check3:enable:param1=blah:param2:param3 )

Eclass would be __QA_ECLASS_DIRECTIVE__, but the same syntax.

I'm proposing this parse syntax:

check_config: dict[str, dict[str, str]] = {}
for x in array.split():
  check, s = x.split(":", 1)
  settings = {}
  for x in s.split(","):
     if '=' not in x:
        x += "=enable"
     k,v = x.split("=", 1)
     settings[k] = v
  check_configs[check] = settings

As to the mapping of "these settings" to "this check", I expect just using the check name (case sensitive) is best. That feels noisy however, but I think this is safest while also making backwards compatibility of renaming checks trivial to address- it's just an alias of what QA directive to load the name(s) from.

Lack of any setting, for example, just a raw ( check ), is implicitly check:enable=true. Sub settings that lack an assignment are implicity true. check:enable is check:enable=true. These are equivalent: check:requires_bash5.3 == check:requires_bash5.3=enable. IE these are all the same: check1 == check1:enable == check1:enable=true

I specifically propose this as a single var; this reduces possible leaks of QA directives in source whilst also allowing to flag directives that no longer mean anything.

I don't propose this as a metadata variable, although that would optimize things. Until some day we have layered metadata caches (this for emerge usage, that for QA), it's not worth the cost. If this comes to pass, then something like ``QA_DIRECTIVE`- eclass and ebuilds- makes sense, since we can treat it as stacked, and just render it L -> R to get the final directives.

The origin of this idea is that I'm actually in the process of moving all snakeoil and pkgcore python QA enforcement over to something similar. That code however self-annotates; I'm proposing we do the same to bash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions