lib/php_codesniffer/plugin.rb in danger-php_codesniffer-0.1.5 vs lib/php_codesniffer/plugin.rb in danger-php_codesniffer-0.1.6

- old
+ new

@@ -28,10 +28,16 @@ # An attribute for enabling filtering # Only show messages within changed files. # @return [Boolean] attr_accessor :filtering + # An attribute for failing on errors + # In case phpcs finds errors, Danger will also fail + # This allows failing pipelines using the `--fail-on-errors` flag in Danger + # @return [Boolean] + attr_accessor :fail_on_error + # Execute and process phpcs CLL's result. # # @return [void] def exec bin = phpcs_path @@ -61,9 +67,12 @@ end markdown "# PHP_CodeSniffer report" markdown generate_summary_markdown summary markdown report + if fail_on_error && summary["errors"] > 0 + fail "There are #{summary["errors"]} errors that need to be resolved." + end end private # Get phpcs' bin path