Sha256: 0ffe9ea1177571645d42206f4c3639f90a02ed21c0c63811c56971c050d6f4fe

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

# frozen_string_literal: true

module SolargraphTestCoverage
  # Some guard functions for the diagnostics
  module ReporterGuards
    def has_test_file?(source)
      File.file? FileHelpers.test_file(source)
    end

    def is_test_file?(source)
      source.location.filename.start_with? FileHelpers.test_path
    end

    def is_test_support_file?(source)
      is_test_file?(source) && !source.location.filename.end_with?(Config.test_file_suffix)
    end

    def exclude_file?(source)
      Config.exclude_paths.any? { |path| source.location.filename.sub(Dir.pwd, '').include? path }
    end

    def using_debugger?(source)
      source.code.include?('binding.pry') ||
        source.code.include?('byebug') ||
        source.code.include?('debugger')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solargraph_test_coverage-0.3.0 lib/solargraph_test_coverage/reporter_guards.rb