Sha256: 8a45b822be6691bfb7f65e880321cf313e5ea0e47a0c74206b37633aa86ecdbc

Contents?: true

Size: 1014 Bytes

Versions: 5

Compression:

Stored size: 1014 Bytes

Contents

# frozen_string_literal: true

module Quality
  module Tools
    # Adds 'cane' tool support to quality gem
    class Cane < Tool
      def cane_exclude_args
        [
          "--abc-exclude '#{source_files_exclude_glob}'",
          "--style-exclude '#{source_files_exclude_glob}'",
          "--doc-exclude '#{source_files_exclude_glob}'",
        ]
      end

      def ruby_files_glob
        "{#{ruby_files.join(',')}}"
      end

      def cane_args
        args = [
          "-f '#{ruby_files_glob}'",
        ]
        args += cane_exclude_args unless exclude_files.nil? || exclude_files.empty?
        args.join(' ')
      end

      def quality_cane
        ratchet_quality_cmd('cane', gives_error_code_on_violations: true,
                                    args: cane_args,
                                    emacs_format: true) do |line|
          if line =~ /\(([0-9]*)\):$/
            Regexp.last_match[1].to_i
          else
            0
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
quality-40.0.1 lib/quality/tools/cane.rb
quality-40.0.0 lib/quality/tools/cane.rb
quality-39.0.1 lib/quality/tools/cane.rb
quality-38.0.1 lib/quality/tools/cane.rb
quality-38.0.0 lib/quality/tools/cane.rb