<commit_before>require 'active_support/core_ext/module/delegation'
require 'shellwords'

module Travis
  module Build
    class Data
      class Env
        delegate :secure_env_enabled?, :pull_request, :config, :build, :job, :repository, to: :data

        class Group < Struct.new(:source, :vars)
          def announce?
            source != 'travis' && vars && vars.length > 0
          end
        end

        attr_reader :data

        def initialize(data)
          @data = data
        end

        def vars
          travis_vars + settings_vars + config_vars
        end

        def vars_groups
          [Group.new('travis',   travis_vars),
           Group.new('repository settings', settings_vars),
           Group.new('config file', config_vars)]
        end

        private

          def travis_vars
            to_vars(
              TRAVIS_PULL_REQUEST:    pull_request || false,
              TRAVIS_SECURE_ENV_VARS: secure_env_vars?,
              TRAVIS_BUILD_ID:        build[:id],
              TRAVIS_BUILD_NUMBER:    build[:number],
              TRAVIS_BUILD_DIR:       [ BUILD_DIR, repository[:slug].shellescape ].join('/'),
              TRAVIS_JOB_ID:          job[:id],
              TRAVIS_JOB_NUMBER:      job[:number],
              TRAVIS_BRANCH:          job[:branch].shellescape,<commit_msg>It's better to ensure vars is an array in initializer than in if checks<commit_after>require 'active_support/core_ext/module/delegation'
require 'shellwords'

module Travis
  module Build
    class Data
      class Env
        delegate :secure_env_enabled?, :pull_request, :config, :build, :job, :repository, to: :data

        class Group < Struct.new(:source, :vars)
          def initialize(source, vars)
            super(source, vars || [])
          end

          def announce?
            source != 'travis' && vars.length > 0
          end
        end

        attr_reader :data

        def initialize(data)
          @data = data
        end

        def vars
          travis_vars + settings_vars + config_vars
        end

        def vars_groups
          [Group.new('travis',   travis_vars),
           Group.new('repository settings', settings_vars),
           Group.new('config file', config_vars)]
        end

        private

          def travis_vars
            to_vars(
              TRAVIS_PULL_REQUEST:    pull_request || false,
              TRAVIS_SECURE_ENV_VARS: secure_env_vars?,
              TRAVIS_BUILD_ID:        build[:id],
              TRAVIS_BUILD_NUMBER:    build[:number],
              TRAVIS_BUILD_DIR:       [ BUILD_DIR, repository[:slug].shellescape ].join('/'),
              TRAVIS_JOB_ID:          job[:id],
              TRAVIS_JOB_NUMBER:      job[:number],
              TRAVIS_BRANCH:          job[:branch].shellescape,
{'fraction_non_alphanumeric': 0.08957887223411849, 'fraction_numerical': 0.0007137758743754461, 'mean_word_length': 1.811434302908726, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6247022', 'n_tokens_mistral': 804, 'n_tokens_neox': 795, 'n_words': 179}