Skip to content

fix-regex doesn't appear to work on generic #1819

Open
@davidfraser

Description

I've been trying to use fix-regex for rules applying across an entire codebase, using the generic language type. However, the rule seems to be ignored. Here's a basic use case:

rules:
- id: test-regex-pytxt
  patterns:
  - pattern: 'print(my, name)'
  fix-regex:
    regex: '(.*)\)'
    replacement: '\1, flush=True)'
  message: Honour where honour's due
  languages: [generic]
  severity: WARNING

- id: test-regex-py
  patterns:
  - pattern-either:
    - pattern: 'print(my, name)'
  fix-regex:
    regex: '(.*)\)'
    replacement: '\1, flush=True)'
  message: Honour where honour's due
  languages: [python]
  severity: WARNING

With a Python file:

print(my, name)

and a text file:

print(my, name)

semgrep with the above config and -a fixes the Python file to print(my, name, flush=True). The text file detects the [generic] rule match, but leaves the file unchanged, and doesn't apply the fix.

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