class Govuk::Lint::ConfigFile

def absolutize_paths(config)

def absolutize_paths(config)
  config["inherit_from"].map do |filename|
    File.join(CONFIG_PATH, "rubocop/#{filename}")
  end
end

def config_file_path

def config_file_path
  return BASE_CONFIG_FILE unless File.exist?(local_config_file_path)
  tempfile_for_configs.path
end

def load_global_config

def load_global_config
  YAML.load_file(BASE_CONFIG_FILE)
end

def local_config_file_path

def local_config_file_path
  @local_config_file_path ||= File.join(Dir.pwd, ".rubocop.yml")
end

def merged_global_and_local_configs

def merged_global_and_local_configs
  config = load_global_config
  config["inherit_from"] = absolutize_paths(config)
  config["inherit_from"] << local_config_file_path
  config
end

def tempfile_for_configs

def tempfile_for_configs
  @tempfile_for_configs ||= begin
                             file = Tempfile.new("tmp-rubocop-all.yml")
                             file.write(merged_global_and_local_configs.to_yaml)
                             file.close
                             file
                           end
end