phpro / grumphp

A PHP code-quality tool
MIT License
4.11k stars 429 forks source link

GrumPhp is not able to validate a valid regular expression for branch name validation #1078

Closed sandipansaha closed 1 year ago

sandipansaha commented 1 year ago
Q A
Version 1.15.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets NA

GrumPhp is not able to validate a valid regular expression for branch name validation My branch name: feature/grumphp-setup validating with: "/(hotfix|bugfix|feature|release|task)\/([a-z|0-9|-]+)$/" image image

My configuration

# grumphp.yml
# Please add a copy of your grumphp.yml file.
# Project level GrumPHP configuration for Magento 2
grumphp:
    hide_circumvention_tip: true
    process_timeout: 120
    stop_on_failure: false
    ignore_unstaged_changes: false
    tasks:
        jsonlint:
            detect_key_conflicts: true
            metadata:
                priority: 100
        xmllint:
            ignore_patterns:
                - "#test/(.*).xml#"
            metadata:
                priority: 100
        phplint:
            triggered_by: ['php', 'phtml']
            metadata:
                priority: 200
        yamllint:
            ignore_patterns:
                - "#test/(.*).yml#"
                - "#charts/.*#"
            metadata:
                priority: 100
        composer:
            file: ./composer.json
            no_check_all: true
            no_check_lock: false
            no_check_publish: false
            with_dependencies: false
            strict: false
            metadata:
                priority: 80
        # validate git commit message
        git_commit_message:
            allow_empty_message: false
            enforce_capitalized_subject: false
            enforce_no_subject_punctuations: false
            enforce_no_subject_trailing_period: true
            enforce_single_lined_subject: true
            type_scope_conventions: []
            max_body_width: 80
            max_subject_width: 80
            matchers:
                "Commit message must contain issue topic and number": /^\[(HOTFIX|BUGFIX|FEATURE|INFRA|MERGE|RELEASE)]\sICRSICRP-\d+\s::\s.*\s\[(COMPLETED|WIP)]/
            case_insensitive: true
            multiline: false
            additional_modifiers: ''
        # validate git branch names
        git_branch_name:
            whitelist:
                # allowed branch names: 'feature/1', 'feature/new', 'feature/new1', 'feature/new-test', 'task/1', etc
                - "/(hotfix|bugfix|feature|release|task)\/([a-z|0-9|-]+)$/"
            blacklist:
                - "development"
                - "production"
                - "staging"
                - "master"
                - "infra"
            allow_detached_head: true
        # catch not allowed keywords
        git_blacklist:
            keywords:
                - "\\.dev"
                - "\\.local"
                - "\\.test"
                - "<<<<<<<"
                - "======="
                - "DebuggerUtility"
                - "ObjectManager::getInstance"
                - "_GET\\["
                - "_POST\\["
                - "_REQUEST\\["
                - "console.log("
                - "die("
                - "die;"
                - "exit("
                - "exit;"
                - "fileadmin"
                - "localhost"
                - "phpinfo"
                - "phpinfo("
                - "print_r("
                - "var_dump("
                - "_objectManager"
                - "ObjectManagerInterface"
            triggered_by: ['php', 'js', 'html', 'phtml']
            metadata:
                priority: 90
        # https://devdocs.magento.com/guides/v2.4/coding-standards/code-standard-php.html
        phpcs:
            standard: Magento2
            tab_width: 4
            severity: 10 # can remove this to dis allow all level of severity.
            error_severity: 10
            warning_severity: ~
            report: full
            triggered_by: [phtml, php]
            metadata:
                priority: 70
        phpcsfixer2:
            allow_risky: false
            config: '.php_cs.dist'
            triggered_by: ['php', 'phtml']
            using_cache: true
            cache_file: './.php_cs.cache'
            config_contains_finder: true
            verbose: true
        phpmd:
            ruleset: ['./dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml']
            triggered_by: ['php']
            exclude:
                - "./app/code/Magento/"
                - "./app/code/*/*/Setup/"
            metadata:
                priority: 70
        #  uncomment to skip modules using whitelist patterns
        #  whitelist_patterns:
        #     - /^app\/code\/MyVendor\/MyModuleToSkip\/(.*)/

        # https://devdocs.magento.com/guides/v2.4/test/testing.html#phpstan
        phpstan:
            autoload_file: ~
            configuration: './dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon'
            level: 8
            triggered_by: ['php']
            force_patterns: []
            ignore_patterns: []
            memory_limit: "-1"
            metadata:
                priority: 90
        phpversion:
            project: '8.1'

Steps to reproduce:

# Generate empty folder
mkdir tmp
cd tmp
git init
echo "vendor" > .gitignore
pbpaste > grumphp.yml
composer require --dev phpro/grumphp

# Your actions
# Please add the steps on how to reproduce the issue here.
git checkout -b feature/grumphp-setup
# Run GrumPHP:
git add -A && git commit -m"Test"
# or
./vendor/bin/grumphp run

Result:

# Please add the result of the run or git commit actions here.
git_branch_name
===============

Whitelist rule not matched: /(hotfix|bugfix|feature|release|task)/([a-z|0-9|-]+)$/
sandipansaha commented 1 year ago

closing as duplicate and answer is provided at https://github.com/phpro/grumphp/issues/1013