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.

Configure Codacy to stop flagging valid "assert" statements

See original GitHub issue

I’m submitting a …

  • bug report
  • feature request

Current behavior: Put a valid assert statement in Python code and Codacy will flag it:

Expected behavior:

  • Codacy does not complain about valid Python.

Steps to fix: https://support.codacy.com/hc/en-us/articles/207279979-Issues#2-remove-pattern

NOTES:

On Mon, Oct 30, 2017 at 12:52 PM, "Ruxandra Barbu" <ruxandra.barbu@codacy.intercom-mail.com>
wrote: 
Hi, thank you for contacting us.
Flagging the Python assert statements is a function of the Bandit linter itself.
You can ignore this issue in Codacy so it won´t affect the project. Please click here for
more details on how to ignore an issue/remove a pattern.
Please let me know if you have any other questions.

On Mon, Oct 30, 2017 at 01:55 AM, "cclauss" wrote: 
Why does Codacy flag the Python assert statements that pytest recommends? I know about the
optimization that eliminates the asserts commands from production code but 1) no one ever
does that and 2) if I did it, I would consider it a feature not a problem. Anyway, I how do
I configure Codacy to stop flagging the asserts that Pytest recommends?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

11reactions
toonarmycaptaincommented, Sep 19, 2018

It seems to me that the primary issue here is distinguishing between tests/testing code and project/production code. I don’t want to turn off the checking for asserts in my project code, but I do want the asserts used (sensibly) in my tests to pass checks for asserts silently.

Seems to me a solution would be to have a separate category for testing code, or code that pytest would run as tests, so I can turn on/off the “Assert used” pattern separately for testing/main project code.

2reactions
toonarmycaptaincommented, Jul 8, 2019

@manoadamro Well unless you’re working on assessments or worksheets maybe (eg test_templates, test_solutions), but once you run into this issue you’d think you’d change the filenames, or have all your tests under test_suite, You can then do:

exclude_paths:
    - 'test_suite/**'

In your .codacy.yml file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring code patterns - Codacy Quality docs
Configure the static analysis tools and code patterns that Codacy uses to ... To solve flagged valid Python "assert" statements, create a bandit.yml...
Read more >
Configuring code patterns - Codacy docs
Configure the static analysis tools and code patterns that Codacy uses to ... To solve flagged valid Python "assert" statements, create a ...
Read more >
Configuring code patterns - Codacy docs
Enable or disable the code patterns using the checkbox for each pattern. ... To solve flagged valid Python "assert" statements, create a ...
Read more >
Code patterns - Codacy docs
However, you can create a coding standard adapted to your scenario by ... To solve flagged valid Python "assert" statements, create a ...
Read more >
Codacy configuration file
To disable a tool you must use the Code patterns page instead. ... Add your settings to the configuration file based on the...
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