<commit_before># encoding: utf-8
module Phare
  class Check
    class JSHint < Check
      attr_reader :config, :path

      def initialize(directory, options = {})
        @config = File.expand_path("#{directory}.jshintrc", __FILE__)
        @path = File.expand_path("#{directory}app/assets/javascripts", __FILE__)
        @glob = File.join(@path, '**/*')
        @extensions = %w(.js .es6)
        @options = options

        super
      end

      def command
        if @tree.changed?
          "jshint --config #{@config} --extra-ext #{@extensions.join(',')} #{files_to_check.join(' ')}"
        else
          "jshint --config #{@config} --extra-ext #{@extensions.join(',')} #{@glob}"
        end
      end

    protected

      def excluded_list
        configuration_file.split("\n") if configuration_file
      end

      def configuration_file
        @configuration_file ||= File.exist?('.jshintignore') ? File.open('.jshintignore') : false
      end

      def binary_exists?
        !Phare.system_output('which jshint').empty?
      end

      def configuration_exists?
        File.exist?(@config)
      end

      def arguments_exists?
        @tree.changed? || Dir.exist?(@path)<commit_msg>Fix issue with .jshintignore<commit_after># encoding: utf-8
module Phare
  class Check
    class JSHint < Check
      attr_reader :config, :path

      def initialize(directory, options = {})
        @config = File.expand_path("#{directory}.jshintrc", __FILE__)
        @path = File.expand_path("#{directory}app/assets/javascripts", __FILE__)
        @glob = File.join(@path, '**/*')
        @extensions = %w(.js .es6)
        @options = options

        super
      end

      def command
        if @tree.changed?
          "jshint --config #{@config} --extra-ext #{@extensions.join(',')} #{files_to_check.join(' ')}"
        else
          "jshint --config #{@config} --extra-ext #{@extensions.join(',')} #{@glob}"
        end
      end

    protected

      def excluded_list
        configuration_file.split("\n") if configuration_file
      end

      def configuration_file
        @configuration_file ||= File.exist?('.jshintignore') ? File.read('.jshintignore') : false
      end

      def binary_exists?
        !Phare.system_output('which jshint').empty?
      end

      def configuration_exists?
        File.exist?(@config)
      end

      def arguments_exists?
        @tree.changed? || Dir.exist?(@path)
{'fraction_non_alphanumeric': 0.14132674083230326, 'fraction_numerical': 0.0016481252575195715, 'mean_word_length': 2.3489655172413793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2455365', 'n_tokens_mistral': 740, 'n_tokens_neox': 716, 'n_words': 156}