Sha256: 0da739e07c8e369c56ba64c80de13cec04754bf2ec64621fe433a6e350df5e5f

Contents?: true

Size: 903 Bytes

Versions: 20

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

module Quality
  module Tools
    # Adds 'bigfiles' tool support to quality gem
    class Jscs < Tool
      def jscs_args
        '-r unix ' + js_files.join(' ')
      end

      def jscs_check_configured
        return 0 if js_files.empty?

        puts 'No JSCS config found!  To generate one, run ' \
             'jscs --auto-configure representative_file.js'
        0
      end

      def jscs_count_violations_on_line(line)
        if line =~ /^.*:\d+:\d+: /
          1
        elsif line =~ /^No configuration found/
          jscs_check_configured
        else
          0
        end
      end

      def quality_jscs
        ratchet_quality_cmd('jscs',
                            args: jscs_args,
                            gives_error_code_on_violations: true) do |line|
          jscs_count_violations_on_line(line)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
quality-40.0.1 lib/quality/tools/jscs.rb
quality-40.0.0 lib/quality/tools/jscs.rb
quality-39.0.1 lib/quality/tools/jscs.rb
quality-38.0.1 lib/quality/tools/jscs.rb
quality-38.0.0 lib/quality/tools/jscs.rb
quality-37.1.1 lib/quality/tools/jscs.rb
quality-37.1.0 lib/quality/tools/jscs.rb
quality-37.0.1 lib/quality/tools/jscs.rb
quality-37.0.0 lib/quality/tools/jscs.rb
quality-36.1.0 lib/quality/tools/jscs.rb
quality-36.0.0 lib/quality/tools/jscs.rb
quality-35.2.1 lib/quality/tools/jscs.rb
quality-35.2.0 lib/quality/tools/jscs.rb
quality-35.1.1 lib/quality/tools/jscs.rb
quality-35.0.1 lib/quality/tools/jscs.rb
quality-35.0.0 lib/quality/tools/jscs.rb
quality-34.0.2 lib/quality/tools/jscs.rb
quality-34.0.1 lib/quality/tools/jscs.rb
quality-34.0.0 lib/quality/tools/jscs.rb
quality-33.0.0 lib/quality/tools/jscs.rb