Abort rake task only on error

Do not exit by default.

Change-Id: I0db37ed4582eba11c2017cbe5ee58644ea1b45f5
Reviewed-on: http://gerrit.causes.com/44455
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Reorganize Parser class

Extract helper methods from the `initialize` method of this class to
make it easier to understand.

Change-Id: Ic2fea460522dfad1d8c45887f48a9a51d1675691
Reviewed-on: http://gerrit.causes.com/44717
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Don't remove last child of root node in haml 4.1+

Version 4.1.0.beta.1 of the `haml` gem no longer creates the special
"EOD" (end of document) nodes when parsing the tree.

Thus we need to only trim this node for versions 4.0.5 and earlier.

Change-Id: I46c4e6887e04157936a29866113db3412de43efd
Reviewed-on: http://gerrit.causes.com/44718
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Fix TagNode#object_reference? for haml 4.1+

Version 4.1.0.beta.1 of the `haml` gem changed the parsing of tag nodes
without object references to set the `:object_ref` key of the value to
the symbol `:nil` instead of the string `'nil'`.

Fix this by always converting to a string before comparing.

Change-Id: I7ec6a5ab51fad4358274c1f2932ffbd1720d0328
Reviewed-on: http://gerrit.causes.com/44719
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Update changelog with haml 4.1.0.beta.1 fixes

Change-Id: I03e1d8803d2b0052cdc17e10467ded065cf2aa65
Reviewed-on: http://gerrit.causes.com/44720
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Fix bundler warning about Rubocop dependency

When running `bundle install` inside this repository, a warning similar
to the following would be displayed:

  haml-lint at /Users/shane/src/haml-lint did not have a valid gemspec.
  This prevents bundler from installing bins or native extensions, but
  that may not affect its functionality.
  The validation message from Rubygems was:
    duplicate dependency on rubocop (= 0.27.1, development), (>= 0.25.0)
    use:
        add_runtime_dependency 'rubocop', '= 0.27.1', '>= 0.25.0'

This was because we were declaring the pinned version of RuboCop as a
development dependency in the gemspec. This turns out to not be
technically correct, as it's not really a development dependency, but a
testing one (i.e. we don't want to enforce this requirement for
developers using this gem when developing other gems that require this
gem).

It turns out a way get around this is to declare the pinned version in
the `Gemfile`, before the call to `gemspec` (you'll still get the
warning if you declare it after).

Change-Id: If6c312bbdc20b7eff3ca4242fc6a872bf35c0884
Reviewed-on: http://gerrit.causes.com/44721
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Use https for Rubygems source

Change-Id: I2424cd07974ce2f525627b5711d2c56f3652de4a
Reviewed-on: http://gerrit.causes.com/44722
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Update gem description

This tool is less "opinionated" now that it supports configuration.

Change-Id: I887939bd3a4401c297e2d213d9e8445a04086eb3
Reviewed-on: http://gerrit.causes.com/44723
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Amend gem description

The tool is configurable--let's emphasize that.

Change-Id: Iad3e2dfc483a71ce381d08e4b475fba8f77692bc
Reviewed-on: http://gerrit.causes.com/44726
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Cut version 0.8.0

Change-Id: I929281ac162719f3fb4245ffcca0ced58264b4a8
Reviewed-on: http://gerrit.causes.com/44727
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Fix LeadingCommentSpace linter failing on empty comment lines

If you comment out multiple lines in haml, there are often empty lines
which just have the '-#' for the comment. The TrailingWhitespace linter
does not allow a space at the end of the line but the
LeadingCommentSpace linter requires it.

This commit fixes the LeadingCommentSpace linter by allowing a comment
without a leading whitespace if the comment is empty.

Change-Id: Ibba637c7068d967b9c8b209ea90e18dad1d5c2a3
Reviewed-on: http://gerrit.causes.com/44884
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Joe Lencioni <joe.lencioni@brigade.com>
Add .editorconfig file

Change-Id: If46f0794b608552b8846445653769da892f13a17
Reviewed-on: http://gerrit.causes.com/44916
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Remove EOD node from haml versions matching ~> 4.0.0

`haml` 4.0.6 was recently released, which breaks the fix implemented in
b504293.

The solution was to use the `Gem::Requirement` class so we always remove
the EOD node for all versions that are in the 4.0.x series.

Change-Id: I75fc7d5036cc5fb870f55ddb8302f772b5e46ead
Reviewed-on: http://gerrit.causes.com/44957
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Specify language in Travis configuration

Make `travis-lint` check happy.

Change-Id: I4ab89ea547fc5c9fe646b4937ea8b51754385829
Reviewed-on: http://gerrit.causes.com/44958
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Fix wording in README

Double use of "some" read a bit odd here.

Change-Id: Iff52e099a7386143645b472e2539c2a7ca8fdc0b
Reviewed-on: http://gerrit.causes.com/44990
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Support multiline comments for `Node#text`

Fetching the text associated with a HAML comment was not returned past
the first line for multiline comments. Fix this by override the `text`
method to fetch each subsequent line.

This required the introduction of a `Node#successor` method to serve the
same purpose as `Linter#next_node`, but on the `Node` itself.

Change-Id: If97def771749185c9a67fddb1afcc9a244747058
Reviewed-on: http://gerrit.causes.com/44991
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Keep only the minimum text for multiline comments

Previously, the following code:

    -#
      One line

      Two line

    %notice-multiple-spaces

...would have resulted in comment text with extra trailing lines:

   "\nOne line\nTwo line\n\n"

This was because we were including lines up to the successor node.
Strip trailing whitespace to fix it.

Change-Id: Ia87922275c1a8387be0a69faea8bce7bdfe06a4a
Reviewed-on: http://gerrit.causes.com/44992
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Fix HamlCommentNode#text

There were a couple more bugs with this implementation when extracting
text from comments at the end of a HAML document or containing spaces.

Change-Id: Ie525c10403da4d3048a54d605a5cd630e52b3bfc
Reviewed-on: http://gerrit.causes.com/44995
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Add tests for HamlLint::Tree::Node

This class was started to have some complicated logic in its methods
that are intended to be consumed by linters. Ensure these are working as
expected by adding some tests.

Change-Id: Idf6322d82eb9130b5955a01f7a655c4f2cc5d0f9
Reviewed-on: http://gerrit.causes.com/44994
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
Add specs for HamlCommentNode

Turns out there were still some bugs with this class's implementation of
`text`, so add some tests and fix the relevant bugs.

Change-Id: I450002ea19c54c8edf9236b0f9772a4789c67cb5
Reviewed-on: http://gerrit.causes.com/44993
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>