Skip to content

Commit

Permalink
natural_language: Add SpellCheckBear
Browse files Browse the repository at this point in the history
This bear uses ``scspell`` to check for spelling mistakes.

Closes #629
  • Loading branch information
mr-karan authored and AbdealiLoKo committed Sep 3, 2016
1 parent 8a3d7fd commit b3be8f3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bears/natural_language/SpellCheckBear.py
@@ -0,0 +1,24 @@
from coalib.bearlib.abstractions.Linter import linter
from coalib.bears.requirements.PipRequirement import PipRequirement


@linter(executable='scspell',
use_stderr=True,
output_format='regex',
output_regex=r'(?P<filename>.*):(?P<line>.\d*):\s*(?P<message>.*)')
class SpellCheckBear:
"""
Lints files to check for incorrect spellings using ``scspell``.
See <https://pypi.python.org/pypi/scspell> for more information.
"""
LANGUAGES = {"Natural Language"}
REQUIREMENTS = {PipRequirement('scspell3k', '2.0')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Spelling'}

@staticmethod
def create_arguments(filename, file, config_file):
return '--report-only', filename
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -28,3 +28,4 @@ pyyaml==3.*
vulture==0.10.*
nbformat>=4.*
pyflakes==1.2.* # Although we don't need this directly, solves a dep conflict
scspell3k==2.*
17 changes: 17 additions & 0 deletions tests/natural_language/SpellCheckBearTest.py
@@ -0,0 +1,17 @@
import platform
import unittest

from bears.natural_language.SpellCheckBear import SpellCheckBear
from tests.LocalBearTestHelper import verify_local_bear

good_file = "This is correct spelling."

bad_file = "tihs si surly som incoreclt speling."


SpellCheckLintBearTest = unittest.skipIf(
platform.system() == "Windows",
"SpellCheckBear doesn't work on windows")(
verify_local_bear(SpellCheckBear,
valid_files=(good_file,),
invalid_files=(bad_file,)))

0 comments on commit b3be8f3

Please sign in to comment.