Skip to content

The .alexrc.yml file should allow or deny words per selected file #340

Open
@tymonx

Description

Subject of the feature

The .alexrc.yml file should allow or deny words per selected file.

Problem

It is not possible to allow or deny some words per selected files. Sometimes is needed to allow some words in files but in other files not. For example license Apache 2.0 file contains executed and failure words.

Download Apache 2.0 file:

wget https://www.apache.org/licenses/LICENSE-2.0.txt

Run alex:

podman run -it --rm --volume "$(pwd):/alex:ro,z" --workdir "/alex" registry.gitlab.com/pipeline-components/alex:0.21.9 --why .

It returns status code 1 and prints:

LICENSE-2.0.txt
  136:34-136:42  warning  Be careful with `executed`, it’s profane in some cases  executed  retext-profanities
  161:54-161:61  warning  Be careful with `failure`, it’s profane in some cases   failure   retext-profanities

⚠ 2 warnings

Creating .alexignore file is not an option because of these issues:

Also it will entirely ignore content of whole file and this is also not desired.

Expected behaviour

Create .alexrc.yml with this content:

allow:
    - file: LICENSE
      words: [executed, failure]

    - file: fifo.cpp
      words: [pop]

It will be also nice if the file: entry will also support glob *.txt, **/*.cpp or regexp .*\.md$ patterns.

Still it should be possible to have backward compatibility with this YAML schema:

allow:
    - executed
    - failure
    - pop

Because it almost all YAML parser libraries it is possible to retrieve YAML type:

  • !!seq is YAML list []
  • !!map is YAML object {}

Alternatives

Create .alexrc.yml with this content:

allow:
    - executed
    - failure
    - pop

But this allow these words in all files.

Other alternative is using .alexignore file but this will ignore content of whole file and there is also still this issue: #170

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