Sha256: 4119f4ff4fc0810eafafa3ddf1cda2585e8b3f4f025fcbe2203d5920539fbfb3

Contents?: true

Size: 1.13 KB

Versions: 64

Compression:

Stored size: 1.13 KB

Contents

namespace :ci do
  desc 'linguist'
  task linguist: 'ci:rugged:setup' do
    require 'linguist'

    def linguist_loc_metrics(language, line_count, percent)
      metrics = [
        {
          name: 'linguist_code_count', type: :gauge,
          label_set: { language: language }, value: line_count
        },
        {
          name: 'linguist_code_percent', type: :gauge,
          label_set: { language: language }, value: percent.round(1)
        }
      ]
      puts metrics.inspect
      metrics
    end

    @metrics ||= []

    project = Linguist::Repository.new(@repo, @repo.head.target_id)
    total_line_count = project.languages.values.reduce(:+)
    other_line_count = 0

    project.languages.each do |language, line_count|
      percent = 100.0 * line_count / total_line_count

      if percent > 1
        @metrics.concat(linguist_loc_metrics(language, line_count, percent))
      else
        other_line_count += line_count
      end
    end

    if other_line_count > 0
      other_percent = 100.0 * other_line_count / total_line_count
      @metrics.concat(linguist_loc_metrics('Other', other_line_count, other_percent))
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
ndr_dev_support-6.1.0 lib/tasks/ci/linguist.rake
ndr_dev_support-6.0.4 lib/tasks/ci/linguist.rake
ndr_dev_support-6.0.3 lib/tasks/ci/linguist.rake
ndr_dev_support-6.0.2 lib/tasks/ci/linguist.rake
ndr_dev_support-6.0.1 lib/tasks/ci/linguist.rake
ndr_dev_support-6.0.0 lib/tasks/ci/linguist.rake
ndr_dev_support-5.10.2 lib/tasks/ci/linguist.rake
ndr_dev_support-5.10.1 lib/tasks/ci/linguist.rake
ndr_dev_support-5.10.0 lib/tasks/ci/linguist.rake
ndr_dev_support-5.9.0 lib/tasks/ci/linguist.rake
ndr_dev_support-5.8.2 lib/tasks/ci/linguist.rake
ndr_dev_support-5.8.1 lib/tasks/ci/linguist.rake
ndr_dev_support-5.8.0 lib/tasks/ci/linguist.rake
ndr_dev_support-5.7.1 lib/tasks/ci/linguist.rake
ndr_dev_support-5.7.0 lib/tasks/ci/linguist.rake
ndr_dev_support-5.6.0 lib/tasks/ci/linguist.rake
ndr_dev_support-5.5.0 lib/tasks/ci/linguist.rake
ndr_dev_support-5.4.8 lib/tasks/ci/linguist.rake
ndr_dev_support-5.4.7 lib/tasks/ci/linguist.rake
ndr_dev_support-5.4.6 lib/tasks/ci/linguist.rake