lib/php_codesniffer/plugin.rb in danger-php_codesniffer-0.1.0 vs lib/php_codesniffer/plugin.rb in danger-php_codesniffer-0.1.1
- old
+ new
@@ -12,16 +12,21 @@
# @see golface/danger-php_codesniffer
# @tags monday, weekends, time, rattata
#
class DangerPhpCodesniffer < Plugin
- # An attribute that you can read/write from your Dangerfile
+ # An attribute for setting code standard
#
+ # @return [String]
+ attr_accessor :standard
+
+ # An attribute for ignoring file or directory
+ #
# @return [String]
attr_accessor :ignore
- # Enable filtering
+ # An attribute for enabling filtering
# Only show messages within changed files.
# @return [Boolean]
attr_accessor :filtering
# Execute and process phpcs CLL's result.
@@ -73,9 +78,10 @@
#
# @return [Hash]
def run_phpcs(bin, file)
command = "#{bin} --report=json "
command << "--basepath=. "
+ command << "--standard=#{standard}" if standard
command << "--ignore=#{ignore}" if ignore
result = `#{command} #{file}`
JSON.parse result
end