Skip to content

Commit

Permalink
.coafile: Activate remove_all_unused_imports
Browse files Browse the repository at this point in the history
Adds flakes section to check non-builtin unused imports.
Automatic fixes may remove critical imports.
Adds ignore comment to non-builtin imports as required.
Removes unused import where necessary.

Closes coala#1600
  • Loading branch information
yash-nisar committed Apr 14, 2017
1 parent 7ef64db commit 72bc27f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
8 changes: 8 additions & 0 deletions .coafile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ language = python
default_actions = *: ApplyPatchAction
preferred_quotation = '

[flakes]
# Do not set default_action to ApplyPatchAction as it may lead to some
# required imports being removed which might result in coala behaving weirdly.
default_action: *: ShowPatchAction
bears = PyUnusedCodeBear
language = Python
remove_all_unused_imports = true

[autopep8]
bears = PEP8Bear, PycodestyleBear
default_actions = PEP8Bear: ApplyPatchAction
Expand Down
2 changes: 2 additions & 0 deletions bears/Constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

# Start ignoring PyUnusedCodeBear
from bears import VERSION
# Stop ignoring PyUnusedCodeBear

# Path to the bears directory
bears_root = os.path.dirname(__file__)
1 change: 0 additions & 1 deletion bears/c_languages/ClangBear.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from clang.cindex import Index, LibclangError

from coalib.bears.LocalBear import LocalBear
from dependency_management.requirements.PipRequirement import PipRequirement
from coalib.results.Diff import Diff
from coalib.results.Result import Result
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
Expand Down
1 change: 0 additions & 1 deletion bears/css/StyleLintBear.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import json
from coalib.bearlib.abstractions.Linter import linter
from dependency_management.requirements.NpmRequirement import NpmRequirement
Expand Down
2 changes: 0 additions & 2 deletions bears/perl/PerlCriticBear.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import platform

from coalib.bearlib.abstractions.Linter import linter
from dependency_management.requirements.DistributionRequirement import (
DistributionRequirement)
Expand Down
1 change: 0 additions & 1 deletion bears/ruby/RubySyntaxBear.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from coalib.bearlib.abstractions.Linter import linter
from dependency_management.requirements.GemRequirement import GemRequirement
from dependency_management.requirements.DistributionRequirement import (
DistributionRequirement)

Expand Down
2 changes: 0 additions & 2 deletions tests/css/StyleLintBearTest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import os
import re
from queue import Queue
from shutil import which
from unittest.case import skipIf

from bears.css.StyleLintBear import StyleLintBear
from coalib.testing.LocalBearTestHelper import LocalBearTestHelper
from coalib.settings.Section import Section
from coalib.settings.Setting import Setting


@skipIf(which('stylelint') is None, 'Stylelint is not installed')
Expand Down
2 changes: 0 additions & 2 deletions tests/haskell/GhcModBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

from bears.haskell.GhcModBear import GhcModBear
from coalib.testing.LocalBearTestHelper import LocalBearTestHelper
from coalib.testing.LocalBearTestHelper import verify_local_bear
from coalib.testing.BearTestHelper import generate_skip_decorator
from coalib.settings.Section import Section
from coalib.settings.Setting import Setting


# A simple hello world program!
Expand Down
3 changes: 1 addition & 2 deletions tests/haskell/HaskellLintBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from bears.haskell.HaskellLintBear import HaskellLintBear
from coalib.testing.LocalBearTestHelper import LocalBearTestHelper
from coalib.testing.LocalBearTestHelper import verify_local_bear
from coalib.testing.BearTestHelper import generate_skip_decorator
from coalib.settings.Section import Section
from coalib.settings.Setting import Setting


good_single_line_file = """
myconcat = (++)
Expand Down

0 comments on commit 72bc27f

Please sign in to comment.