Coder Social home page Coder Social logo

git_blacklist never runs? about grumphp HOT 5 OPEN

cerw avatar cerw commented on July 3, 2024
git_blacklist never runs?

from grumphp.

Comments (5)

veewee avatar veewee commented on July 3, 2024

Hello,

It is not executed during grumphp run since it uses the git staged files to detect these keywords.
it only runs during pre-commit.

from grumphp.

cerw avatar cerw commented on July 3, 2024

Hello,

It is not executed during grumphp run since it uses the git staged files to detect these keywords. it only runs during pre-commit.

Hello there,

Thanks for getting to me so fast, true ! but still not failing ?

GrumPHP detected a pre-commit command.
GrumPHP is sniffing your code!

Running tasks with priority 0!
==============================

Running task 1/8: file_size... ✔
Running task 2/8: phpcs... ✔
Running task 3/8: git_branch_name... ✔
Running task 4/8: jsonlint...
Running task 5/8: phplint... ✔
Running task 6/8: securitychecker_enlightn...
Running task 7/8: git_blacklist...
Running task 8/8: composer...
🤖 Skipping gptcommit because the githook isn't set up for the "Message" commit mode.
GrumPHP detected a commit-msg command.
GrumPHP is sniffing your code!

Running tasks with priority 0!
==============================

Running task 1/1: git_commit_message... ✔

Changes:

➜ nanospa git:(last_bits_on_spa) git diff b31aeafbf0a35c506cd4d3828113e7b7f192865b

─────────────────────────────────────────────────────────────────────────────────┐
app/Listeners/LogUserHasLoggedOff.php:29: public function handle(Logout $logout) │
─────────────────────────────────────────────────────────────────────────────────┘
29 ⋮ 29 │ // no user is logged in
30 ⋮ 30 │ return;
31 ⋮ 31 │ }
32 ⋮ │ dd(1);
⋮ 32 │ dd(2);
33 ⋮ 33 │ activity()
34 ⋮ 34 │ ->useLog('auth')
35 ⋮ 35 │ ->event('logout')

─────────────────────────┐
grumphp.yml:48: grumphp: │
─────────────────────────┘
48 ⋮ 48 │ - "dd("
49 ⋮ 49 │ - "var_dump("
50 ⋮ 50 │ - "exit;"
51 ⋮ │ # whitelist_patterns:
52 ⋮ │ # - add(
⋮ 51 │ whitelist_patterns:
⋮ 52 │ - add(
53 ⋮ 53 │ regexp_type: G
54 ⋮ │ match_word: true
⋮ 54 │ match_word: false
55 ⋮ 55 │ composer:


What has changed?


from grumphp.

veewee avatar veewee commented on July 3, 2024

It might be so, that you need to apply keyword escaping, since ( is a reserved regex character.
See examples here:
https://github.com/phpro/grumphp/blob/v2.x/doc/tasks/git_blacklist.md

from grumphp.

cerw avatar cerw commented on July 3, 2024

Hmm can not get it work, it runs but it has no tick?

image

Tried with " without, with match_word on and off..

grumphp:
  stop_on_failure: true
  process_timeout: 210
  parallel:
    enabled: true
    max_workers: 32
  tasks:
    file_size:
      max_size: 3M
      ignore_patterns: []
    phpcs:
      standard: PSR2
      warning_severity: 0
      error_severity: 1
      ignore_patterns:
        - ./tests
        - ./resources/*
        - ./database
        - ./bootstrap
        - ./public
        - ./config/
    git_branch_name:
      # whitelist:
      #   - '/([0-9]+)-/'
      #   - '/bugfix-*/'
      blacklist:
        - "/(shit|fuck|crap)/"
      # - "develop"
      # - "master"
    git_commit_message:
      allow_empty_message: false
      enforce_capitalized_subject: false
      enforce_no_subject_trailing_period: true
      enforce_single_lined_subject: false
      max_body_width: 400
      max_subject_width: 200
      case_insensitive: true
      multiline: true
      additional_modifiers: ""
    jsonlint: null
    phplint: null
    securitychecker_enlightn:
      lockfile: ./composer.lock
    git_blacklist:
      keywords:
        - die\\(
        - dump\\(
        - dd\\(
        - var_dump\\(
        - exit;
      whitelist_patterns:
        - add(
      regexp_type: G
      match_word: false
    composer:

from grumphp.

veewee avatar veewee commented on July 3, 2024

Not sure what's going wrong there, it seems to be working on my specific setup.
Maybe you'dd rather use something like
https://github.com/phpro/grumphp/blob/v2.x/doc/tasks/phpparser.md

Or phpstan with https://github.com/ekino/phpstan-banned-code.

Both use PHP's AST to figure out if it's allowed or not which is less error prone on input like dump[space](
Whilst the blacklist task only checks for a regex match.

from grumphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.