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

Add support for function signature blocked, wildcard character & rule allowed modules #30

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

piyushgarg-juspay
Copy link
Collaborator

  • Add allowed modules list for function rule (by default all modules are allowed)
  • Add support for wildcard character "*" in function rules
  • Add support for blocking functions with a particular type signature (Signature only) (by default no signature check)
  • Add test rules in sheriff rules

Example rule for above changes:

# We should get the errors for below functions two times only in Test1
  - fn_rule_name: Test Allowed Modules
    fn_name:
      - throwExceptionV2
      - TestUtils.throwExceptionV4
    arg_no: 0
    fns_blocked_in_arg: []
    types_blocked_in_arg: []
    types_to_check_in_arg: []
    fn_rule_fixes:
      - You are not allowed to use helper function `throwException` from `TestUtils` module.
      - Use `throwExceptionV2` or `throwExceptionV4` function from `TestUtils` module.
    fn_rule_exceptions: []
    fn_rule_ignore_modules: []
    fn_rule_allowed_modules:
      - "Test1"
    
  # We should get error for usage of any function with Number type
  - fn_rule_name: Test Functions usage blocked having any function name with given signature
    fn_name:
      - "*"
    arg_no: 0
    fn_sigs_blocked:
      - Number -> TestUtils1.Number -> * # Should not throw Error
      - Number -> Number -> Number # Should throw Error
      - TestUtils.Number -> TestUtils.Number -> TestUtils.Number # Should throw Error
      - Maybe (Either (Maybe (Int)) (Maybe (Int))) -> Number -> Number -> Number # Should throw Error
    fns_blocked_in_arg: []
    types_blocked_in_arg: []
    types_to_check_in_arg: []
    fn_rule_fixes:
      - Contact senior dev for the solution.
    fn_rule_exceptions: []
    fn_rule_ignore_modules: []
    fn_rule_allowed_modules:
      - Test1

Example output:
image

@piyushgarg-juspay piyushgarg-juspay merged commit dab36f6 into ghc-9.2.8 Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant