Skip to content

Commit

Permalink
bears: Add JuliaLintBear
Browse files Browse the repository at this point in the history
Linting for Julia using Lint.jl
https://github.com/tonyhffong/Lint.jl

Fixes coala#23
  • Loading branch information
SanketDG committed Feb 28, 2016
1 parent b146a2a commit a3d8411
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .ci/deps.osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ brew install sqlite && brew link sqlite --force
brew install openssl && brew link openssl --force
brew install gnu-indent
brew install go
brew tap staticfloat/julia
brew install julia

# Install required go libraries
go get -u github.com/golang/lint/golint
Expand All @@ -34,3 +36,6 @@ pip install -q -r requirements.txt

# Calling setup.py will download checkstyle automatically so tests may succeed
python setup.py --help

# julia
julia -e "Pkg.add(\"Lint\")"
7 changes: 6 additions & 1 deletion .ci/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ esac

# apt-get commands
sudo add-apt-repository -y ppa:marutter/rdev
sudo add-apt-repository -y ppa:staticfloat/juliareleases
sudo add-apt-repository -y ppa:staticfloat/julia-deps
sudo apt-get -qq update
deps="espeak libclang1-3.4 indent mono-mcs chktex hlint r-base"
deps="espeak libclang1-3.4 indent mono-mcs chktex hlint r-base julia"
deps_python_dbus="libdbus-glib-1-dev libdbus-1-dev"
deps_python_gi="glib2.0-dev gobject-introspection libgirepository1.0-dev python3-cairo-dev"
deps_perl="perl libperl-critic-perl"
Expand Down Expand Up @@ -55,3 +57,6 @@ python setup.py --help
# Dart Lint commands
wget -nc -O ~/dart-sdk.zip https://storage.googleapis.com/dart-archive/channels/stable/release/1.14.2/sdk/dartsdk-linux-x64-release.zip
unzip -n ~/dart-sdk.zip -d ~/

# Julia commands
julia -e "Pkg.add(\"Lint\")"
22 changes: 22 additions & 0 deletions bears/julia/JuliaLintBear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from coalib.bearlib.abstractions.Lint import Lint
from coalib.bears.LocalBear import LocalBear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY


class JuliaLintBear(LocalBear, Lint):
executable = 'julia'
arguments = '-e \'import Lint.lintfile; lintfile({filename})\''
output_regex = r'(^.*\.jl):(?P<line>\d+) (?P<severity>.)\d+ (?P<message>.*)'
use_stdout = True
severity_map = {
"E": RESULT_SEVERITY.MAJOR,
"W": RESULT_SEVERITY.NORMAL,
"I": RESULT_SEVERITY.INFO
}

def run(self, filename, file):
'''
Lints Julia code using ``Lint.jl``.
https://github.com/tonyhffong/Lint.jl
'''
return self.lint(filename, file)
Empty file added bears/julia/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions tests/julia/JuliaLintBearTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from bears.julia.JuliaLintBear import JuliaLintBear
from tests.LocalBearTestHelper import verify_local_bear

good_file = """
a = 2
println(2)
""".splitlines(keepends=True)

bad_file = """
println(hello)
""".splitlines(keepends=True)

JuliaLintBearTest = verify_local_bear(JuliaLintBear,
valid_files=(good_file,),
invalid_files=(bad_file,),
tempfile_kwargs={"suffix": ".jl"},
timeout=45)
Empty file added tests/julia/__init__.py
Empty file.

0 comments on commit a3d8411

Please sign in to comment.