From 7ff36e9105f080a538f0bc4922045be22e03db9c Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Tue, 21 Jul 2015 19:44:23 -0700 Subject: [PATCH 1/3] Rename config.yml -> phpqa.yml --- config.yml => phpqa.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config.yml => phpqa.yml (100%) diff --git a/config.yml b/phpqa.yml similarity index 100% rename from config.yml rename to phpqa.yml From 018d00bb4d371dcc87b38250f4dbed6e5e4f69c4 Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Tue, 21 Jul 2015 19:45:28 -0700 Subject: [PATCH 2/3] Update reference to phpqa.yml --- src/Config.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Config.php b/src/Config.php index 75267db..af8bf1c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -11,14 +11,21 @@ class Config { + /** + * @var array + */ protected $config; - protected $custom = false; + /** + * @var boolean + */ + protected $custom; public function __construct() { + $this->custom = false; $this->config = []; - $this->loadFile(__DIR__.'/../'.'config.yml'); + $this->loadFile(__DIR__.'/../'.'phpqa.yml'); if ($this->getApplicationConfigFile()) { $this->loadFile($this->getApplicationConfigFile()); $this->custom = true; @@ -98,7 +105,7 @@ public function getApplicationConfigFile() public function loadProjectConfiguration($project) { - if ($this->custom) { + if ($this->isCustom()) { return; } @@ -155,4 +162,12 @@ public function getProjectAnalyzerConfigFile($project, $analyzer) return '--'.$analyserConfigOption.'='.$analyserConfigFile; } + + /** + * @return boolean + */ + public function isCustom() + { + return $this->custom; + } } From 70ebdf7c208c76b46ca771acdd2172ad6da06853 Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Tue, 21 Jul 2015 19:46:03 -0700 Subject: [PATCH 3/3] Fixes to AnalyzeCommand classes --- src/Command/AnalyzeCommand.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Command/AnalyzeCommand.php b/src/Command/AnalyzeCommand.php index 32a2b84..192eeb0 100644 --- a/src/Command/AnalyzeCommand.php +++ b/src/Command/AnalyzeCommand.php @@ -23,16 +23,16 @@ protected function configure() ->setName('analyze') ->setDescription('Analyze code') ->addOption( - 'files', + 'project', null, - InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, - 'File(s) to avalyze' + InputOption::VALUE_OPTIONAL, + 'Project name must be (php, symfony, drupal) or could be empty if a phpqa.yml or phpqa.yml.dist exists at current directory.' ) ->addOption( - 'project', + 'files', null, - InputOption::VALUE_REQUIRED, - 'Project name' + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + 'File(s) to analyze' ); } @@ -49,6 +49,14 @@ protected function execute(InputInterface $input, OutputInterface $output) * @var \JMOlivas\Phpqa\Config $config */ $config = $application->getConfig(); + + if (!$project && !$config->isCustom()) { + throw new \Exception( + 'No local phpqa.yml or phpqa.yml.dist at current working directory ' . + 'you must provide a valid project name (php, symfony or drupal)' + ); + } + $config->loadProjectConfiguration($project); $this->directory = $application->getApplicationDirectory();