<commit_before><?php

namespace Akeneo\CouplingDetector\Console\Command;

use Akeneo\CouplingDetector\Coupling\UseViolations;
use Akeneo\CouplingDetector\Detector;
use Akeneo\CouplingDetector\Coupling\UseViolationsFilter;
use Akeneo\CouplingDetector\FilesReader;
use Akeneo\CouplingDetector\RulesApplier;
use Akeneo\CouplingDetector\UseViolationRule;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Detects the coupling issues in pim-community-dev
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2015 Akeneo SAS (http://www.akeneo.com)
 * @license   http://opensource.org/licenses/MIT MIT
 */
class PimCommunityCommand extends Command
{
    /**
     * {@inheritedDoc}
     */
    protected function configure()
    {
        $this
            ->setName('pim-community-dev')
            ->setDefinition(
                array(
                    new InputOption(
                        'output',
                        '',
                        InputOption::VALUE_REQUIRED, 'Output mode, "default", "count", "none"', 'default'
                    ),
                    new InputOption('strict', '', InputOption::VALUE_NONE, 'Apply strict rules without legacy exceptions'),
                )
            )
            ->setDescription('Detect coupling violations in pim-community-dev');
    }

    /**
     * {@inheritedDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $this->getProjectPath();
        $strictMode = $input->getOption('strict');
        $displayMode = $input->getOption('output');

        if ('none' !== $displayMode) {
            $output->writeln(
                sprintf(
                    '<info> Detect coupling violations (strict mode %s)</info>',
                    $strictMode ? 'enabled' : 'disabled'
                )
            );
        }

        $rules = [
            new UseViolationRule(
                'Akeneo\Component',
                ['Pim', 'PimEnterprise', 'Bundle', 'Doctrine\ORM']
            ),
            new UseViolationRule(
                'Akeneo\Bundle',
                ['Pim', 'PimEnterprise']
            ),
            new UseViolationRule(
                'Pim\Component',
                ['PimEnterprise', 'Bundle', 'Doctrine\ORM']
            ),
            new UseViolationRule(
                'Pim\Bundle',
                ['PimEnterprise']
            ),
            new UseViolationRule(
                'Pim\Bundle\CatalogBundle',
                ['EnrichBundle', 'UIBundle', 'TransformBundle', 'BaseConnectorBundle', 'ConnectorBundle', 'BatchBundle']
            ),
        ];

        $legacyExclusions = [
            // TranslatableInterface should be moved in a Akeneo component
            'Akeneo\Component\Classification\Updater\CategoryUpdater' => [
                'Pim\Bundle\TranslationBundle\Entity\TranslatableInterface'
            ],
            // Repository interfaces should never expose QueryBuilder as parameter
            'Akeneo\Component\Classification\Repository' => [
                'Doctrine\ORM\QueryBuilder'
            ],
            'Pim\Component\Connector' => [
                // Interfaces of BatchBundle should be extracted in an Akeneo component
                'Akeneo\Bundle\BatchBundle\Entity\StepExecution',
                'Akeneo\Bundle\BatchBundle\Entity\JobExecution',
                'Akeneo\Bundle\BatchBundle\Item\InvalidItemException',
                'Akeneo\Bundle\BatchBundle\Item\ItemProcessorInterface',
                'Akeneo\Bundle\BatchBundle\Item\ItemReaderInterface',
                'Akeneo\Bundle\BatchBundle\Item\UploadedFileAwareInterface',
                'Akeneo\Bundle\BatchBundle\Item\AbstractConfigurableStepElement',
                'Akeneo\Bundle\BatchBundle\Item\ItemWriterInterface',
                'Akeneo\Bundle\BatchBundle\Job\RuntimeErrorException',
                'Akeneo\Bundle\BatchBundle\Step\AbstractStep',
                'Akeneo\Bundle\BatchBundle\Step\StepExecutionAwareInterface',
                // Model interfaces of CatalogBundle should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Model\ProductInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeInterface',
                'Pim\Bundle\CatalogBundle\Model\AssociationTypeInterface',
                'Pim\Bundle\CatalogBundle\Model\FamilyInterface',
                'Pim\Bundle\CatalogBundle\Model\GroupInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeOptionInterface',
                'Pim\Bundle\CatalogBundle\Model\ProductValueInterface',
                // Repositories interfaces of CatalogBundle should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\LocaleRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\CurrencyRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\GroupTypeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\AssociationTypeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\ChannelRepositoryInterface',
                // AttributeTypes of CatalogBundle should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\AttributeType\AttributeTypes',
                'Pim\Bundle\CatalogBundle\AttributeType\AbstractAttributeType',
                // We need to check why we use these classes, interfaces should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Manager\AttributeValuesResolver',
                'Pim\Bundle\CatalogBundle\Manager\ProductTemplateApplierInterface',
                'Pim\Bundle\CatalogBundle\Validator\Constraints\File',
                // For factories and builders of CatalogBundle, interfaces should be created in the catalog component
                'Pim\Bundle\CatalogBundle\Builder\ProductBuilderInterface',
                'Pim\Bundle\CatalogBundle\Factory\AttributeFactory',
                'Pim\Bundle\CatalogBundle\Factory\AssociationTypeFactory',
                'Pim\Bundle\CatalogBundle\Factory\FamilyFactory',
                'Pim\Bundle\CatalogBundle\Factory\GroupFactory',
                // Version manager should be exploded with SRP and introduce different interfaces in a component
                'Pim\Bundle\VersioningBundle\Manager\VersionManager'
            ],
            // Connector component should not rely on base connector file writer, move the implementation in BC manner
            'Pim\Component\Connector\Writer\File\YamlWriter' => [
                'Pim\Bundle\BaseConnectorBundle\Writer\File\FileWriter'
            ],
            'Pim\Bundle\CatalogBundle\Repository' => [
                // CatalogBundle repository interfaces should not rely on an EnrichBundle DataTransformer interface,
                // this enrich interface is not even related to UI and should be moved
                'Pim\Bundle\EnrichBundle\Form\DataTransformer\ChoicesProviderInterface',
                // CatalogBundle repository interfaces should not rely on a UIBundle repository interface, this ui
                // interface should be moved
                'Pim\Bundle\UIBundle\Entity\Repository\OptionRepositoryInterface'
            ],
            // CatalogBundle MongoDB normalizers should not use a TransformBundle normalizer, will be better to
            // duplicate code or extract<commit_msg>Add legacy exclusion for catalog component<commit_after><?php

namespace Akeneo\CouplingDetector\Console\Command;

use Akeneo\CouplingDetector\Coupling\UseViolations;
use Akeneo\CouplingDetector\Detector;
use Akeneo\CouplingDetector\Coupling\UseViolationsFilter;
use Akeneo\CouplingDetector\FilesReader;
use Akeneo\CouplingDetector\RulesApplier;
use Akeneo\CouplingDetector\UseViolationRule;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Detects the coupling issues in pim-community-dev
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2015 Akeneo SAS (http://www.akeneo.com)
 * @license   http://opensource.org/licenses/MIT MIT
 */
class PimCommunityCommand extends Command
{
    /**
     * {@inheritedDoc}
     */
    protected function configure()
    {
        $this
            ->setName('pim-community-dev')
            ->setDefinition(
                array(
                    new InputOption(
                        'output',
                        '',
                        InputOption::VALUE_REQUIRED, 'Output mode, "default", "count", "none"', 'default'
                    ),
                    new InputOption('strict', '', InputOption::VALUE_NONE, 'Apply strict rules without legacy exceptions'),
                )
            )
            ->setDescription('Detect coupling violations in pim-community-dev');
    }

    /**
     * {@inheritedDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $this->getProjectPath();
        $strictMode = $input->getOption('strict');
        $displayMode = $input->getOption('output');

        if ('none' !== $displayMode) {
            $output->writeln(
                sprintf(
                    '<info> Detect coupling violations (strict mode %s)</info>',
                    $strictMode ? 'enabled' : 'disabled'
                )
            );
        }

        $rules = [
            new UseViolationRule(
                'Akeneo\Component',
                ['Pim', 'PimEnterprise', 'Bundle', 'Doctrine\ORM']
            ),
            new UseViolationRule(
                'Akeneo\Bundle',
                ['Pim', 'PimEnterprise']
            ),
            new UseViolationRule(
                'Pim\Component',
                ['PimEnterprise', 'Bundle', 'Doctrine\ORM']
            ),
            new UseViolationRule(
                'Pim\Bundle',
                ['PimEnterprise']
            ),
            new UseViolationRule(
                'Pim\Bundle\CatalogBundle',
                ['EnrichBundle', 'UIBundle', 'TransformBundle', 'BaseConnectorBundle', 'ConnectorBundle', 'BatchBundle']
            ),
        ];

        $legacyExclusions = [
            // TranslatableInterface should be moved in a Akeneo component
            'Akeneo\Component\Classification\Updater\CategoryUpdater' => [
                'Pim\Bundle\TranslationBundle\Entity\TranslatableInterface'
            ],
            // Repository interfaces should never expose QueryBuilder as parameter
            'Akeneo\Component\Classification\Repository' => [
                'Doctrine\ORM\QueryBuilder'
            ],
            'Pim\Component\Catalog' => [
                // Model interfaces of CatalogBundle should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Model\ChannelInterface',
                'Pim\Bundle\CatalogBundle\Model\LocaleInterface',
                'Pim\Bundle\CatalogBundle\Model\ProductValueInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeInterface',
                'Pim\Bundle\CatalogBundle\Model\ProductInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeOptionInterface',
                'Pim\Bundle\CatalogBundle\Model\AssociationInterface',
                'Pim\Bundle\CatalogBundle\Model\CategoryInterface',
                'Pim\Bundle\CatalogBundle\Model\FamilyInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeGroupInterface',
                'Pim\Bundle\CatalogBundle\Model\GroupInterface',
                'Pim\Bundle\CatalogBundle\Model\AssociationTypeInterface',
                'Pim\Bundle\CatalogBundle\Model\ProductTemplateInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeRequirementInterface',
                // Repository interfaces of CatalogBundle should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\ChannelRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\GroupTypeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\LocaleRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\AttributeGroupRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\AttributeRequirementRepositoryInterface',
                // Builder interface should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Builder\ProductBuilderInterface',
                // Extract at least an interface of these factories in the catalog component (ideally move implem too)
                'Pim\Bundle\CatalogBundle\Factory\FamilyFactory',
                'Pim\Bundle\CatalogBundle\Factory\AttributeRequirementFactory',
                'Pim\Bundle\CatalogBundle\Factory\MetricFactory',
                // What to do with this class?
                'Pim\Bundle\CatalogBundle\Validator\AttributeValidatorHelper',
                // Extract this exception in the component, it should be more accurate than InvalidArgumentException
                // as it looks only used in updaters
                'Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException',
                // Avoid to use this manager, extract an interface from this or maybe use repository and depreciate it
                'Pim\Bundle\CatalogBundle\Manager\CurrencyManager',
                // What to do with this, cannot be extracted due to dependencies to symfony form
                'Pim\Bundle\CatalogBundle\AttributeType\AbstractAttributeType',
                'Pim\Bundle\CatalogBundle\AttributeType\AttributeTypes',
                // Deprecated in 1.5, should be dropped the deprecated methods support
                'Pim\Bundle\CatalogBundle\Updater\ProductUpdaterInterface'
            ],
            'Pim\Component\Connector' => [
                // Interfaces of BatchBundle should be extracted in an Akeneo component
                'Akeneo\Bundle\BatchBundle\Entity\StepExecution',
                'Akeneo\Bundle\BatchBundle\Entity\JobExecution',
                'Akeneo\Bundle\BatchBundle\Item\InvalidItemException',
                'Akeneo\Bundle\BatchBundle\Item\ItemProcessorInterface',
                'Akeneo\Bundle\BatchBundle\Item\ItemReaderInterface',
                'Akeneo\Bundle\BatchBundle\Item\UploadedFileAwareInterface',
                'Akeneo\Bundle\BatchBundle\Item\AbstractConfigurableStepElement',
                'Akeneo\Bundle\BatchBundle\Item\ItemWriterInterface',
                'Akeneo\Bundle\BatchBundle\Job\RuntimeErrorException',
                'Akeneo\Bundle\BatchBundle\Step\AbstractStep',
                'Akeneo\Bundle\BatchBundle\Step\StepExecutionAwareInterface',
                // Model interfaces of CatalogBundle should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Model\ProductInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeInterface',
                'Pim\Bundle\CatalogBundle\Model\AssociationTypeInterface',
                'Pim\Bundle\CatalogBundle\Model\FamilyInterface',
                'Pim\Bundle\CatalogBundle\Model\GroupInterface',
                'Pim\Bundle\CatalogBundle\Model\AttributeOptionInterface',
                'Pim\Bundle\CatalogBundle\Model\ProductValueInterface',
                // Repositories interfaces of CatalogBundle should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\LocaleRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\CurrencyRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\GroupTypeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\AssociationTypeRepositoryInterface',
                'Pim\Bundle\CatalogBundle\Repository\ChannelRepositoryInterface',
                // What to do with this, cannot be extracted due to dependencies to symfony form
                'Pim\Bundle\CatalogBundle\AttributeType\AttributeTypes',
                'Pim\Bundle\CatalogBundle\AttributeType\AbstractAttributeType',
                // We need to check why we use these classes, interfaces should be extracted in the catalog component
                'Pim\Bundle\CatalogBundle\Manager\AttributeValuesResolver',
                'Pim\Bundle\CatalogBundle\Manager\ProductTemplateApplierInterface',
                'Pim\Bundle\CatalogBundle\Validator\Constraints\File',
                // For factories and builders of CatalogBundle, interfaces should be created in the catalog component
                'Pim\Bundle\CatalogBundle\Builder\ProductBuilderInterface',
                'Pim\Bundle\CatalogBundle\Factory\AttributeFactory',
                'Pim\Bundle\CatalogBundle\Factory\AssociationTypeFactory',
                'Pim\Bundle\CatalogBundle\Factory\FamilyFactory',
                'Pim\Bundle\CatalogBundle\Factory\GroupFactory',
                // Version manager should be exploded with SRP and introduce different interfaces in a component
                'Pim\Bundle\VersioningBundle\Manager\VersionManager'
            ],
            // Connector component should not rely on base connector file writer, move the implementation in BC manner
            'Pim\Component\Connector\Writer\File\YamlWriter' => [
                'Pim\Bundle\BaseConnectorBundle\Writer\File\FileWriter'
            ],
            'Pim\Bundle\CatalogBundle\Repository' => [
                // CatalogBundle repository interfaces should not rely on an EnrichBundle DataTransformer interface,
                // this enrich interface is not even related to UI and should be moved
                'Pim\Bundle\EnrichBundle\Form\DataTransformer\ChoicesProviderInterface',
                // CatalogBundle repository interfaces should not rely on a UIBundle repository interface, this ui
                // interface should be moved
                'Pim\Bundle\UIBundle\Entity\Repository\OptionRepositoryInterface'
            ],
            // CatalogBundle MongoDB normalizers should not use a TransformBundle normalizer, will be better to
            // duplicate code or extract
{'fraction_non_alphanumeric': 0.08918875329283373, 'fraction_numerical': 0.000537605505080372, 'mean_word_length': 2.183638541844943, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3835487', 'n_tokens_mistral': 4638, 'n_tokens_neox': 4447, 'n_words': 873}