Skip to content

Commit

Permalink
Bears: Add CsvLintBear
Browse files Browse the repository at this point in the history
Closes coala#927
  • Loading branch information
stefanbalas committed Oct 29, 2016
1 parent d955dc2 commit b14c440
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
source 'https://rubygems.org'
ruby '2.1.5'
ruby '2.2.2'

gem "rubocop"
gem "sqlint"
gem 'scss_lint', require: false# require flag is necessary https://github.com/brigade/scss-lint#installation
gem "reek"
gem "puppet-lint"
gem "csvlint"
22 changes: 22 additions & 0 deletions bears/csv/CsvLintBear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from coalib.bearlib.abstractions.Linter import linter


@linter(executable='csvlint',
output_format='regex',
output_regex=r'\d\. (?P<message>.+)\. Row:'
r' (?P<row>\d+)\. (?P<information>.+)',
result_message='This ``csv`` file is invalid.')
class CsvLintBear:
"""
Verifies using ``csvlint`` if ``.csv`` files are valid csv or not.
"""

LANGUAGES = {"csv"}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Syntax'}

@staticmethod
def create_arguments(filename, file, config_file):
return filename,
Empty file added bears/csv/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions tests/csv/CsvLintBearTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from bears.csv.CsvLintBear import CsvLintBear
from tests.LocalBearTestHelper import verify_local_bear

good_file = """
id,first_name,last_name,email,gender,ip_address
1,Cynthia,Rogers,[email protected],Female,158.131.39.207
2,Lisa,Carroll,[email protected],Female,157.69.195.53
3,Kevin,Baker,[email protected],Male,113.189.69.4
"""


bad_file = """
id,first_name,last_name,email,gender,ip_address
1,Cynthia,Rogers,[email protected],Female,158.131.39.207
2,Lisa,Carroll,[email protected],157.69.195.53
3,Kevin,Baker,[email protected],Male,113.189.69.4
"""


CsvLintBearTest = verify_local_bear(CsvLintBear,
valid_files=(good_file,),
invalid_files=(bad_file,))
Empty file added tests/csv/__init__.py
Empty file.

0 comments on commit b14c440

Please sign in to comment.