Ensure trailing newline before passing to Rubocop

Version 0.13.0 of Rubocop introduces a `FinalNewline` lint which causes
a lint to be thrown for every script extracted by the `ScriptExtractor`.

In preparation for an upgrade to 0.13.0, ensure we're appending a
newline to the generated code to avoid these lints.

This also adds an optimization to not even run Rubocop in the event
there is no code to run. This can occur when a HAML template contains no
script code.

Change-Id: I8c46c977cc76a1b182694fbcc353d37bffddc12d
Reviewed-on: https://gerrit.causes.com/28633
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>