<commit_before>package config

import (
	"encoding/json"
	"time"
)

// Config holds metadata about pt's users
type Config struct {
	// CurrentUserID is the current user's ID
	CurrentUserID uint64 `json:"current_user_id"`

	// CurrentUserSetTime is when the current user is set
	CurrentUserSetTime time.Time `json:"current_user_set_time"`

	// Users is the list of pt's users
	Users []User `json:"users"`
}

// User is a PT system user
type User struct {
	// ID given from Tracker
	ID uint64 `json:"id"`

	// APIToken provided from the Tracker's settings page
	APIToken string `json:"api_token"`

	// Name is the real name of the user
	Name string `json:"name"`

	// Username for Tracker
	Username string `json:"username"`

	// Alias setup by the user for quick reference
	Alias string `json:"alias,omitempty"`
}

// AddUser adds users to config with the given credentials. Will error out if:
// - API Token matches another user's API token (DuplicateAliasError)
// - Username matches a saved alias (UsernameMatchesSavedAliasError)
// - Alias matches another user's alias (AliasMatchesSavedUsernameError)
// If a users user is added again (determined by the same ID), the original
// user will be removed from the config.
func (config *Config) AddUser(id uint64, apiToken string, name string, username string, alias string) error {
	newUser := User{
		ID:       id,
		APIToken: apiToken,
		Name:     name,
		Username: username,
		Alias:    alias,
	}

	for i, savedUser := range config.Users {
		if savedUser.ID == newUser.ID {
			config.Users = append(config.Users[:i], config.Users[i+1:]...)
			break
		}
	}

	for _, savedUser := range config.Users {
		switch {
		case newUser.Alias != "" && savedUser.Alias == newUser.Alias:
			return DuplicateAliasError{User: savedUser}<commit_msg>godoc formatting<commit_after>package config

import (
	"encoding/json"
	"time"
)

// Config holds metadata about pt's users
type Config struct {
	// CurrentUserID is the current user's ID
	CurrentUserID uint64 `json:"current_user_id"`

	// CurrentUserSetTime is when the current user is set
	CurrentUserSetTime time.Time `json:"current_user_set_time"`

	// Users is the list of pt's users
	Users []User `json:"users"`
}

// User is a PT system user
type User struct {
	// ID given from Tracker
	ID uint64 `json:"id"`

	// APIToken provided from the Tracker's settings page
	APIToken string `json:"api_token"`

	// Name is the real name of the user
	Name string `json:"name"`

	// Username for Tracker
	Username string `json:"username"`

	// Alias setup by the user for quick reference
	Alias string `json:"alias,omitempty"`
}

// AddUser adds users to config with the given credentials. Will error out if:
//   - API Token matches another user's API token (DuplicateAliasError)
//   - Username matches a saved alias (UsernameMatchesSavedAliasError)
//   - Alias matches another user's alias (AliasMatchesSavedUsernameError)
// If a users user is added again (determined by the same ID), the original
// user will be removed from the config.
func (config *Config) AddUser(id uint64, apiToken string, name string, username string, alias string) error {
	newUser := User{
		ID:       id,
		APIToken: apiToken,
		Name:     name,
		Username: username,
		Alias:    alias,
	}

	for i, savedUser := range config.Users {
		if savedUser.ID == newUser.ID {
			config.Users = append(config.Users[:i], config.Users[i+1:]...)
			break
		}
	}

	for _, savedUser := range config.Users {
		switch {
		case newUser.Alias != "" && savedUser.Alias == newUser.Alias:
			return DuplicateAliasError{User: savedUser}
{'fraction_non_alphanumeric': 0.10343863572826391, 'fraction_numerical': 0.003913894324853229, 'mean_word_length': 3.7706666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '458298', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1068, 'n_words': 404}