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-7.3.1 lib/tasks/ci/linguist.rake
ndr_dev_support-7.3.0 lib/tasks/ci/linguist.rake
ndr_dev_support-7.2.6 lib/tasks/ci/linguist.rake
ndr_dev_support-7.2.5 lib/tasks/ci/linguist.rake
ndr_dev_support-7.2.4 lib/tasks/ci/linguist.rake
ndr_dev_support-7.2.3 lib/tasks/ci/linguist.rake
ndr_dev_support-7.2.2 lib/tasks/ci/linguist.rake
ndr_dev_support-7.2.1 lib/tasks/ci/linguist.rake
ndr_dev_support-7.2.0 lib/tasks/ci/linguist.rake
ndr_dev_support-7.1.0 lib/tasks/ci/linguist.rake
ndr_dev_support-7.0.0 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.9 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.8 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.7 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.6 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.5 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.4 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.3 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.2 lib/tasks/ci/linguist.rake
ndr_dev_support-6.1.1 lib/tasks/ci/linguist.rake