question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning not ignored with pre-commit hook

See original GitHub issue

cfn-lint version: 0.25 Python: 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32 pre-commit: 1.17.0 Description of issue.

I have below in my .pre-commit-config.yaml in my git repository

repos:
  - repo: https://github.com/awslabs/cfn-python-lint
    rev: v0.25.0 # The version of cfn-lint to use
    hooks:
      - id: cfn-python-lint
        name: AWS CloudFormation Linter
        files: cfn_templates/.*\.(yml|yaml)$

When I run pre-commit, I got a warning:

AWS CloudFormation Linter................................................Failed
hookid: cfn-python-lint

W1020 Fn::Sub isn't needed because there are no variables at Resources/KafkaLaunchConfig/Metadata/AWS::CloudFormation::Init/configureKafka/files//opt/kafka/bin/kafka-start.sh/content/Fn::Sub
cfn_templates/kafka_kafkacluster.yaml:244:29

I have already put this section in my cloudformation template:

Metadata:
    cfn-lint:
        config:
            regions:
                - eu-central-1
            ignore_checks:
                - W1020

But I still get the warning. When I run cfn-lint standaone to validate this template, then the warning will not be displayed.

How can I get the validation work with pre-commit? Is there a way to specify ignore checks in .pre-commit-config.yaml?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kddejongcommented, Nov 16, 2019

I’m having troubles replicating this. This template will appropriately skip error W1020 for me. How many other yaml/yml/json files do you have in that repo?

Our entry point is the same as the command line. https://github.com/aws-cloudformation/cfn-python-lint/blob/master/.pre-commit-hooks.yaml#L3

---
Metadata:
  cfn-lint:
    config:
      ignore_checks:
        - W1020
Resources:
  Vpc:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Sub "10.0.0.0/24"
0reactions
mmaengcommented, Oct 26, 2022

I am also having trouble replicating this issue on win32 . Multiple versions of cfn-lint attempted from v0.25.0 in the original report to quite a few versions afterwards, including v0.69.1

Removing the Metadata from the provided kafka_cluster.yaml causes the run to fail but including that part it passes precommit with cfn-lint.

What is your pre-commit-config.yaml and cfn template like @skshahidur ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning not ignored with pre-commit hook #1196 - GitHub
When I run cfn-lint standaone to validate this template, then the warning will not be displayed. How can I get the validation work...
Read more >
Why is my Git pre-commit hook not executable by default?
hint: The 'pre-commit' hook was ignored because it's not set as executable. hint: You can disable this warning with `git config advice.
Read more >
Supported hooks - pre-commit
check-docstring-first - checks a common error of defining a docstring after code. check-executables-have-shebangs - ensures that (non-binary) executables have ...
Read more >
Pre-commit Hook - Prettier
You can use Prettier with a pre-commit tool. This can re-format your files that are marked as “staged” via `git add` before you...
Read more >
pre-commit-hooks - PyPI
Note that no-commit-to-branch is configured by default to always_run . As a result, it will ignore any setting of files , exclude ,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found