Skip to content

Commit

Permalink
Fix various syntax error checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Sep 14, 2016
1 parent 832c916 commit e638107
Show file tree
Hide file tree
Showing 49 changed files with 342 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
configure.in
Makefile.in


######################################
# GENERIC
######################################
Expand All @@ -20,6 +19,8 @@ Makefile.in
*.orig
*.rej

###### python ######
*.pyc

######################################
# Operating Systems
Expand Down
175 changes: 122 additions & 53 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ before_install:

- sudo npm install -g eslint
- sudo npm install -g jsonlint
- sudo npm install -g mdlint
#- sudo npm install -g mdlint
- sudo gem install scss_lint
- sudo gem install mdl

# Symlink node binaries
- sudo ln -s /usr/local/node/bin/* /usr/local/bin/ 2>/dev/null || true
Expand All @@ -48,10 +49,15 @@ before_install:

script:

# Validate coding guidelines of self
#------------------------------------------------------------
# 1.) Validate coding guidelines of self
#------------------------------------------------------------
- shellcheck --exclude=SC1090,SC2001 --shell=bash bin/*

# Output Info

#------------------------------------------------------------
# 2.) Output Info
#------------------------------------------------------------
- bin/file-crlf --info
- bin/file-empty --info
- bin/file-trailing-newline --info
Expand All @@ -78,54 +84,117 @@ script:
- bin/syntax-sh --info


# Test the scripts in dry mode
- bin/file-crlf --path=. --config=etc/awesome-ci.conf --dry
- bin/file-empty --path=. --config=etc/awesome-ci.conf --dry
- bin/file-trailing-newline --path=. --config=etc/awesome-ci.conf --dry
#------------------------------------------------------------
# 3.) Test the scripts in dry mode
#------------------------------------------------------------
- bin/file-crlf --path=. --config=etc/awesome-ci.conf --dry
- bin/file-empty --path=. --config=etc/awesome-ci.conf --dry
- bin/file-trailing-newline --path=. --config=etc/awesome-ci.conf --dry
- bin/file-trailing-single-newline --path=. --config=etc/awesome-ci.conf --dry
- bin/file-trailing-space --path=. --config=etc/awesome-ci.conf --dry
- bin/file-utf8 --path=. --config=etc/awesome-ci.conf --dry
- bin/file-utf8-bom --path=. --config=etc/awesome-ci.conf --dry
- bin/git-conflicts --path=. --config=etc/awesome-ci.conf --dry
- bin/git-ignored --path=. --dry
- bin/inline-css --path=. --config=etc/awesome-ci.conf --dry
- bin/inline-js --path=. --config=etc/awesome-ci.conf --dry
- bin/regex-grep --path=. --config=etc/awesome-ci.conf --dry
- bin/regex-perl --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-bash --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-css --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-js --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-json --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-markdown --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-perl --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-php --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-python --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-ruby --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-scss --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-sh --path=. --config=etc/awesome-ci.conf --dry

# Test the scripts in real mode
- bin/file-crlf --path=. --config=etc/awesome-ci.conf
- bin/file-empty --path=. --config=etc/awesome-ci.conf
- bin/file-trailing-newline --path=. --ignore=".git,configure.in" --config=etc/awesome-ci.conf
- bin/file-trailing-single-newline --path=. --ignore=".git,configure.in" --config=etc/awesome-ci.conf
- bin/file-trailing-space --path=. --ignore=".git,configure.in" --config=etc/awesome-ci.conf
- bin/file-utf8 --path=. --config=etc/awesome-ci.conf
- bin/file-utf8-bom --path=. --config=etc/awesome-ci.conf
- bin/git-conflicts --path=. --config=etc/awesome-ci.conf
- bin/git-ignored --path=.
- bin/inline-css --path=. --config=etc/awesome-ci.conf
- bin/inline-js --path=. --config=etc/awesome-ci.conf
#- bin/regex-grep --path=. --config=etc/awesome-ci.conf
#- bin/regex-perl --path=. --config=etc/awesome-ci.conf
- bin/syntax-bash --path=. --config=etc/awesome-ci.conf
- bin/syntax-css --path=. --config=etc/awesome-ci.conf
- bin/syntax-js --path=. --config=etc/awesome-ci.conf
- bin/syntax-json --path=. --config=etc/awesome-ci.conf
- bin/syntax-markdown --path=. --config=etc/awesome-ci.conf
- bin/syntax-perl --path=. --config=etc/awesome-ci.conf
- bin/syntax-php --path=. --config=etc/awesome-ci.conf
- bin/syntax-python --path=. --config=etc/awesome-ci.conf
- bin/syntax-ruby --path=. --config=etc/awesome-ci.conf
- bin/syntax-scss --path=. --config=etc/awesome-ci.conf
- bin/syntax-sh --path=. --config=etc/awesome-ci.conf
- bin/file-trailing-space --path=. --config=etc/awesome-ci.conf --dry
- bin/file-utf8 --path=. --config=etc/awesome-ci.conf --dry
- bin/file-utf8-bom --path=. --config=etc/awesome-ci.conf --dry
- bin/git-conflicts --path=. --config=etc/awesome-ci.conf --dry
- bin/git-ignored --path=. --dry
- bin/inline-css --path=. --config=etc/awesome-ci.conf --dry
- bin/inline-js --path=. --config=etc/awesome-ci.conf --dry
- bin/regex-grep --path=. --config=etc/awesome-ci.conf --dry
- bin/regex-perl --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-bash --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-css --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-js --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-json --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-markdown --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-perl --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-php --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-python --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-ruby --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-scss --path=. --config=etc/awesome-ci.conf --dry
- bin/syntax-sh --path=. --config=etc/awesome-ci.conf --dry


#------------------------------------------------------------
# 4.) Test the scripts in real mode (without findings)
#------------------------------------------------------------
- bin/file-crlf --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/file-empty --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/file-trailing-newline --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/file-trailing-single-newline --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/file-trailing-space --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/file-utf8 --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/file-utf8-bom --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/git-conflicts --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/git-ignored --path=.
- bin/inline-css --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/inline-js --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
#- bin/regex-grep --path=. --config=etc/awesome-ci.conf
#- bin/regex-perl --path=. --config=etc/awesome-ci.conf
- bin/syntax-bash --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-css --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-js --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-json --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-markdown --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-perl --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-php --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-python --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-ruby --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-scss --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"
- bin/syntax-sh --path=. --config=etc/awesome-ci.conf --ignore=".git/,test/,configure.in"


#------------------------------------------------------------
# 5.) Find errors
#------------------------------------------------------------
- bin/file-crlf --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/file-empty --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/file-trailing-newline --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/file-trailing-single-newline --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/file-trailing-space --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/file-utf8 --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/file-utf8-bom --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/git-conflicts --path=test/err/ --config=etc/awesome-ci.conf && false || true
#- bin/git-ignored --path=test/err/
- bin/inline-css --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/inline-js --path=test/err/ --config=etc/awesome-ci.conf && false || true
#- bin/regex-grep --path=test/err/ --config=etc/awesome-ci.conf
#- bin/regex-perl --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-bash --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-css --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-js --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-json --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-markdown --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-perl --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-php --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-python --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-ruby --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-scss --path=test/err/ --config=etc/awesome-ci.conf && false || true
- bin/syntax-sh --path=test/err/ --config=etc/awesome-ci.conf && false || true


#------------------------------------------------------------
# 6.) Find Success
#------------------------------------------------------------
- bin/file-crlf --path=test/err/ --config=etc/awesome-ci.conf
- bin/file-empty --path=test/err/ --config=etc/awesome-ci.conf
- bin/file-trailing-newline --path=test/err/ --config=etc/awesome-ci.conf
- bin/file-trailing-single-newline --path=test/err/ --config=etc/awesome-ci.conf
- bin/file-trailing-space --path=test/err/ --config=etc/awesome-ci.conf
- bin/file-utf8 --path=test/err/ --config=etc/awesome-ci.conf
- bin/file-utf8-bom --path=test/err/ --config=etc/awesome-ci.conf
- bin/git-conflicts --path=test/err/ --config=etc/awesome-ci.conf
#- bin/git-ignored --path=test/err/
- bin/inline-css --path=test/err/ --config=etc/awesome-ci.conf
- bin/inline-js --path=test/err/ --config=etc/awesome-ci.conf
#- bin/regex-grep --path=test/err/ --config=etc/awesome-ci.conf
#- bin/regex-perl --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-bash --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-css --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-js --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-json --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-markdown --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-perl --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-php --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-python --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-ruby --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-scss --path=test/err/ --config=etc/awesome-ci.conf
- bin/syntax-sh --path=test/err/ --config=etc/awesome-ci.conf
2 changes: 1 addition & 1 deletion bin/syntax-css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ENABLE_CUST_OPS=1
# When not specifying --custom,
# always use this as the default options
# to parse to the check binary.
DEFAULT_CUST_OPS="--color"
DEFAULT_CUST_OPS="--color --include-linter \"\""

# How to add your check here:
# ---------------------------
Expand Down
6 changes: 3 additions & 3 deletions bin/syntax-markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MY_FINISH_ERR="Found files with Markdown syntax errors."
MY_CONF_PRE="SYNTAX_MARKDOWN_"

# Custom required binaries
REQUIRED_CUST_BINS="mdlint"
REQUIRED_CUST_BINS="mdl"

# Binaries required for fixing
REQUIRED_FIX_BINS=""
Expand All @@ -27,7 +27,7 @@ ENABLE_CUST_OPS=1
# When not specifying --custom,
# always use this as the default options
# to parse to the check binary.
DEFAULT_CUST_OPS=""
DEFAULT_CUST_OPS="--no-warnings"

# How to add your check here:
# ---------------------------
Expand All @@ -39,7 +39,7 @@ DEFAULT_CUST_OPS=""
# This will be replaced either with custom options
# or with the default options.

MY_CHECK="mdlint __CUSTOM_OPT_PLACEHOLDER__ \"\$1\" 2>&1 | grep -i \"Error\" || true"
MY_CHECK="mdl __CUSTOM_OPT_PLACEHOLDER__ \"\$1\" 2>&1 | grep -i \"Error\" || true"

# Can this check fix the problems?
ENABLE_FIX=0
Expand Down
2 changes: 1 addition & 1 deletion bin/syntax-perl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DEFAULT_CUST_OPS=""
# This will be replaced either with custom options
# or with the default options.

MY_CHECK="perl -c \"\$1\" 2>&1 || true"
MY_CHECK="perl -c \"\$1\" 2>&1 | grep -vE \"[[:space:]]*OK\$\" || true"

# Can this check fix the problems?
ENABLE_FIX=0
Expand Down
2 changes: 1 addition & 1 deletion bin/syntax-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DEFAULT_CUST_OPS=""
# This will be replaced either with custom options
# or with the default options.

MY_CHECK="ruby -c \"\$1\" 2>&1 || true"
MY_CHECK="ruby -c \"\$1\" 2>&1 | grep -vE \"[[:space:]]*OK\$\" || true"

# Can this check fix the problems?
ENABLE_FIX=0
Expand Down
2 changes: 1 addition & 1 deletion bin/syntax-scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ REQUIRED_FIX_BINS=""
# When not specifying --custom,
# always use this as the default options
# to parse to the check binary.
DEFAULT_CUST_OPS="--color"
DEFAULT_CUST_OPS="--color --include-linter \"\""

# How to add your check here:
# ---------------------------
Expand Down
3 changes: 3 additions & 0 deletions test/err/file-crlf_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LINE1
LINE2
LINE3
Empty file added test/err/file-empty_err
Empty file.
1 change: 1 addition & 0 deletions test/err/file-trailing-newline_err
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file does not have a trailing newline
7 changes: 7 additions & 0 deletions test/err/file-trailing-single-newline_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This file does not have a single trailing newline,
but much more





3 changes: 3 additions & 0 deletions test/err/file-trailing-space_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A lot
of trailing
space
1 change: 1 addition & 0 deletions test/err/file-utf8-bom_err
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file contains BOM
2 changes: 2 additions & 0 deletions test/err/file-utf8_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Correct unicode
��
6 changes: 6 additions & 0 deletions test/err/git-conflicts_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
the number of planets are
<<<<<<< HEAD
nine
=======
eight
>>>>>>> branch-a
6 changes: 6 additions & 0 deletions test/err/inline-css_err.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<head></head>
<body style="padding-left:10px;">

</body>
</html?
6 changes: 6 additions & 0 deletions test/err/inline-js_err.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<head></head>
<body>
<a href="javascript:document.forms[0].submit();">test</a>
</body>
</html?
13 changes: 13 additions & 0 deletions test/err/syntax-bash_err.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash


VARIABLE="test"

my_func() {
exut 5

}

if ["test" = "" ]; then
echo "t"

6 changes: 6 additions & 0 deletions test/err/syntax-css_err.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.cla, {
padding-left:10px;
},[
magin:10;
}

1 change: 1 addition & 0 deletions test/err/syntax-js_err.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log({;
4 changes: 4 additions & 0 deletions test/err/syntax-json_err.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"foo": "bar",
"hey": "hoe
}
25 changes: 25 additions & 0 deletions test/err/syntax-markdown_err.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# H1

[test](http://test]

# H1

## H2

### H3

some text

##### H5

--
---
----
-----
------
-------

|tbl|tbl2
---|tbl

foo bar = <
8 changes: 8 additions & 0 deletions test/err/syntax-perl_err.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env perl

# Strict and warnings are recommended.
use strict
use warning

# Print a message.
print "Hello, World!\n";
9 changes: 9 additions & 0 deletions test/err/syntax-php_err.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env php

<?php

echo "test"
function foo() {

return 1;
}
Loading

0 comments on commit e638107

Please sign in to comment.