<commit_before>package builderfile

import (
	"errors"
)

// HandleDeprecatedStanzas returns an error if file contains any deprecated
// stanzas that would cause a failure.  If no failure would be caused, the
// error will be nil, but a warning message will be printed out and file will
// be sanitized to effectively not include the deprecated stanza
func (file *Builderfile) HandleDeprecatedStanzas() error {
	var includedWarningPrinted bool

	for _, container := range file.ContainerArr {
		if len(container.Excluded) != 0 {
			logger.Error(excludedStanzaWarningMessage)
			return errors.New(`container section contains deprecated "excluded" section`)
		}

		if len(container.Included) != 0 {
			container.Included = nil
			if !includedWarningPrinted {
				logger.Warn(includedStanzaWarningMessage)
				includedWarningPrinted = true
			}
		}
	}

	if len(file.ContainerGlobals.Excluded) != 0 {
		logger.Error(excludedStanzaWarningMessage)
		return errors.New(`container section contains deprecated "excluded" section`)
	}

	if len(file.ContainerGlobals.Included) != 0 {
		file.ContainerGlobals.Included = nil
		if !includedWarningPrinted {
			logger.Warn(includedStanzaWarningMessage)
			includedWarningPrinted = true<commit_msg>Making sure we don't panic on parsing if bobfile has no containerglobals<commit_after>package builderfile

import (
	"errors"
)

// HandleDeprecatedStanzas returns an error if file contains any deprecated
// stanzas that would cause a failure.  If no failure would be caused, the
// error will be nil, but a warning message will be printed out and file will
// be sanitized to effectively not include the deprecated stanza
func (file *Builderfile) HandleDeprecatedStanzas() error {
	var includedWarningPrinted bool

	for _, container := range file.ContainerArr {
		if len(container.Excluded) != 0 {
			logger.Error(excludedStanzaWarningMessage)
			return errors.New(`container section contains deprecated "excluded" section`)
		}

		if len(container.Included) != 0 {
			container.Included = nil
			if !includedWarningPrinted {
				logger.Warn(includedStanzaWarningMessage)
				includedWarningPrinted = true
			}
		}
	}

	if file.ContainerGlobals != nil {
		if len(file.ContainerGlobals.Excluded) != 0 {
			logger.Error(excludedStanzaWarningMessage)
			return errors.New(`container section contains deprecated "excluded" section`)
		}

		if len(file.ContainerGlobals.Included) != 0 {
			file.ContainerGlobals.Included = nil
			if !includedWarningPrinted {
				logger.Warn(includedStanzaWarningMessage)
				includedWarningPrinted = true
			}
{'fraction_non_alphanumeric': 0.07782101167315175, 'fraction_numerical': 0.0031128404669260703, 'mean_word_length': 4.540948275862069, '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': '3940301', 'n_tokens_mistral': 825, 'n_tokens_neox': 718, 'n_words': 221}