<commit_before>import React from 'react';
import classNames from 'classnames';
import DefaultProps from '../../defaultProps';

/**
 * Controlled accordion
 */
export default class Accordion extends React.PureComponent {
    static propTypes = {
        ...DefaultProps.propTypes,
        /**
         * Pass false to disable animation
         */
        animating: React.PropTypes.bool,
        /**
         * Current visible content. Strings and numbers are accepted
         */
        activeIndexes: React.PropTypes.arrayOf(React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number])),
        /**
         * React.PropTypes.arrayOf(React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]))
         */
        fluid: React.PropTypes.bool,
        /**
         * An accordion can be formatted to appear on dark backgrounds
         */
        inverted: React.PropTypes.bool,
        /**
         * Callback when accordion wants to be changed
         */
        onAccordionChange: React.PropTypes.func,
        /**
         * A styled accordion adds basic formatting
         */
        styled: React.PropTypes.bool,
    };

    static contextTypes = {
        isAccordionChild: React.PropTypes.bool
    };

    static childContextTypes = {
        isAccordionChild: React.PropTypes.bool
    };

    static defaultProps = {
        ...DefaultProps.defaultProps,
        activeIndexes: [],
        onAccordionChange: () => { }
    };

    getChildContext() {
        return {
            isAccordionChild: true
        };
    }


    /**
     * Accordion title click handler
     *
     * @param {number|string} index Index
     */
    onAccordionTitleClick = (index) => {
        this.props.onAccordionChange(index);
    };

    /**
     * Process children. Skips non active content
     */
    renderChildren() {
        // not using child.type checking because these will fail if using some kind of HOC component
        const arrayChildren = React.Children.toArray(this.props.children);
        const newChild = [];
        for (let index = 0; index < arrayChildren.length; index++) {
            const child = arrayChildren[index];
            if (child.props.index) {
                let active = false;
                // This is accordion title
                if (this.props.activeIndexes.indexOf(child.props.index) !== -1) {
                    // It should be active
                    active = true;
                }
                newChild.push(React.cloneElement(child, {
                    active: active,
                    key: child.key ? child.key : child.props.index,
                    onClick: this.onAccordionTitleClick
                }));
                const body = arrayChildren[index + 1];
                if (body) {
                    newChild.push(
                        React.cloneElement(body, {
                            active: active,
                            key: body.key ? body.key : `content-${child.props.index}`,
                            styled: this.props.styled,
                        })
                    );
                    // skip next element
                    index++;
                }
            }
        }
        return newChild;
    }

    render() {
        const {
            animating, component, children, defaultClasses, activeIndexes, fluid, inverted,
            onAccordionChange, styled, enterAnimation, leaveAnimation, ...other
        } = this.props;
        const Component = component;

        other.className = classNames(other.className, this.getClasses());

        return (
            <Component {...other}>
                {this.renderChildren()}
            </Component>
        )
    }

    getClasses() {<commit_msg>Linting fixes<commit_after>import React from 'react';
import classNames from 'classnames';
import DefaultProps from '../../defaultProps';

/**
 * Controlled accordion
 */
export default class Accordion extends React.PureComponent {
    static propTypes = {
        ...DefaultProps.propTypes,
        /**
         * Pass false to disable animation
         */
        animating: React.PropTypes.bool,
        /**
         * Current visible content. Strings and numbers are accepted
         */
        activeIndexes: React.PropTypes.arrayOf(React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number])),
        /**
         * React.PropTypes.arrayOf(React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]))
         */
        fluid: React.PropTypes.bool,
        /**
         * An accordion can be formatted to appear on dark backgrounds
         */
        inverted: React.PropTypes.bool,
        /**
         * Callback when accordion wants to be changed
         */
        onAccordionChange: React.PropTypes.func,
        /**
         * A styled accordion adds basic formatting
         */
        styled: React.PropTypes.bool
    };

    static contextTypes = {
        isAccordionChild: React.PropTypes.bool
    };

    static childContextTypes = {
        isAccordionChild: React.PropTypes.bool
    };

    static defaultProps = {
        ...DefaultProps.defaultProps,
        activeIndexes: [],
        onAccordionChange: () => { }
    };

    getChildContext() {
        return {
            isAccordionChild: true
        };
    }


    /**
     * Accordion title click handler
     *
     * @param {number|string} index Index
     */
    onAccordionTitleClick = (index) => {
        this.props.onAccordionChange(index);
    };

    /**
     * Process children. Skips non active content
     */
    renderChildren() {
        // not using child.type checking because these will fail if using some kind of HOC component
        const arrayChildren = React.Children.toArray(this.props.children);
        const newChild = [];
        for (let index = 0; index < arrayChildren.length; index++) {
            const child = arrayChildren[index];
            if (child.props.index) {
                let active = false;
                // This is accordion title
                if (this.props.activeIndexes.indexOf(child.props.index) !== -1) {
                    // It should be active
                    active = true;
                }
                newChild.push(React.cloneElement(child, {
                    active: active,
                    key: child.key ? child.key : child.props.index,
                    onClick: this.onAccordionTitleClick
                }));
                const body = arrayChildren[index + 1];
                if (body) {
                    newChild.push(
                        React.cloneElement(body, {
                            active: active,
                            key: body.key ? body.key : `content-${child.props.index}`,
                            styled: this.props.styled
                        })
                    );
                    // skip next element
                    index++;
                }
            }
        }
        return newChild;
    }

    render() {
        const {
            animating, component, children, defaultClasses, activeIndexes, fluid, inverted,
            onAccordionChange, styled, enterAnimation, leaveAnimation, ...other
        } = this.props;
        const Component = component;

        other.className = classNames(other.className, this.getClasses());

        return (
            <Component {...other}>
                {this.renderChildren()}
            </Component>
        )
    }

    getClasses() {
{'fraction_non_alphanumeric': 0.10159574468085106, 'fraction_numerical': 0.0007978723404255319, 'mean_word_length': 1.5221327967806841, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5928256', 'n_tokens_mistral': 1931, 'n_tokens_neox': 1877, 'n_words': 431}