<commit_before>const suffixToRemove = 'Container';

function addDisplayNameStatement(t, varName) {
    const pos = varName.indexOf(suffixToRemove);
    const displayName = 0 < pos ? varName.substring(0, pos) : varName;

    // <VAR>.displayName = '<VAR>';
    return t.expressionStatement( //
        t.assignmentExpression('=', //
            t.memberExpression(t.identifier(varName), t.identifier('displayName')),  // <VAR>.displayName
            t.stringLiteral(displayName)));
}

export default function build({types: t}) {
    return {
        visitor: {
            VariableDeclaration(path, state) {
                if (1 === path.node.declarations.length) {
                    const declarator = path.node.declarations[0];
                    if (t.isIdentifier(declarator.id)) {
                        const varName = declarator.id.name;
                        const initExpression = declarator.init;
                        const {methodName} = state.opts;
                        if (t.isCallExpression(initExpression)) {
                            let callee = initExpression.callee;
                            if (t.isMemberExpression(initExpression.callee)) {
                                callee = callee.object.callee;
                            }
                            if (callee && methodName === callee.name) {
                                const statementPath = t.isExportNamedDeclaration(path.parentPath) ? path.parentPath : path;
                                statementPath.insertAfter(addDisplayNameStatement(t, varName));
                            }
                        }
                    }
                }
            }
        }
    };
}<commit_msg>Fix default value if plugin is not configured<commit_after>const suffixToRemove = 'Container';

function addDisplayNameStatement(t, varName) {
    const pos = varName.indexOf(suffixToRemove);
    const displayName = 0 < pos ? varName.substring(0, pos) : varName;

    // <VAR>.displayName = '<VAR>';
    return t.expressionStatement( //
        t.assignmentExpression('=', //
            t.memberExpression(t.identifier(varName), t.identifier('displayName')),  // <VAR>.displayName
            t.stringLiteral(displayName)));
}

export default function build({types: t}) {
    return {
        visitor: {
            VariableDeclaration(path, state) {
                if (1 === path.node.declarations.length) {
                    const declarator = path.node.declarations[0];
                    if (t.isIdentifier(declarator.id)) {
                        const varName = declarator.id.name;
                        const initExpression = declarator.init;
                        const {methodName = 'reactStamp'} = state.opts;
                        if (methodName && t.isCallExpression(initExpression)) {
                            let callee = initExpression.callee;
                            if (t.isMemberExpression(initExpression.callee)) {
                                callee = callee.object.callee;
                            }
                            if (callee && methodName === callee.name) {
                                const statementPath = t.isExportNamedDeclaration(path.parentPath) ? path.parentPath : path;
                                statementPath.insertAfter(addDisplayNameStatement(t, varName));
                            }
                        }
                    }
                }
            }
        }
    };
}
{'fraction_non_alphanumeric': 0.10227600115240565, 'fraction_numerical': 0.0023048112935753384, 'mean_word_length': 1.4554455445544554, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '2072595', 'n_tokens_mistral': 860, 'n_tokens_neox': 828, 'n_words': 151}