Skip to content

Commit

Permalink
Fix Command-Descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
isfett committed Jan 30, 2020
1 parent bbaf3df commit 7dc70bd
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This tool uses [a php parser written in php](https://github.com/nikic/PHP-Parser
- Find Classes/Functions with the highest cyclomatic complexity
- Halstead-Metrics
- Most Used Constants (Order by name or value)
- IDE-Integration (PHPStorm)

## Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
Expand Down
18 changes: 9 additions & 9 deletions src/Console/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,19 @@ abstract class AbstractCommand extends Command
private const FORMAT_PATH_LINE = '%s:%s';

/** @var string */
protected const FORMAT_PROCESSORS_DONE_MESSAGE = 'Processors processed magic numbers. Magic numbers found: %d';
protected const FORMAT_PROCESSORS_DONE_MESSAGE = '';

/** @var string */
protected const FORMAT_PROCESSORS_PROGRESS_MESSAGE = 'Processor %d is processing magic numbers. Magic numbers found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded
protected const FORMAT_PROCESSORS_PROGRESS_MESSAGE = '';

/** @var string */
private const FORMAT_TO_LINE = '%s%s'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded
private const FORMAT_TO_LINE = '%s%s';

/** @var string */
private const FORMAT_VISITORS_DONE_MESSAGE = 'Visitors checked magic numbers in %d files. Magic numbers found: %d';
protected const FORMAT_VISITORS_DONE_MESSAGE = '';

/** @var string */
private const FORMAT_VISITORS_PROGRESS_MESSAGE = 'Visitors are checking for magic numbers in files. Magic numbers found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded
protected const FORMAT_VISITORS_PROGRESS_MESSAGE = '';

/** @var string */
private const LINE_SEPARATOR = '-'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded
Expand Down Expand Up @@ -431,7 +431,7 @@ protected function parseFiles(array $files, Traverser $traverser, ProgressBar $t
$traverser->setFile($file);
$traverser->traverse($ast);
$traverserProgressBar->setMessage(sprintf(
self::FORMAT_VISITORS_PROGRESS_MESSAGE,
static::FORMAT_VISITORS_PROGRESS_MESSAGE,
$traverser->getNodeOccurrencesCount()
));
}
Expand Down Expand Up @@ -501,15 +501,15 @@ protected function processOccurrences(

foreach ($this->processorRunner->process($occurrenceList) as $processorsDone) {
$processorsProgressBar->setMessage(sprintf(
self::FORMAT_PROCESSORS_PROGRESS_MESSAGE,
static::FORMAT_PROCESSORS_PROGRESS_MESSAGE,
$processorsDone,
count($occurrenceList->getOccurrences())
));
$processorsProgressBar->advance();
}

$processorsProgressBar->setMessage(sprintf(
self::FORMAT_PROCESSORS_DONE_MESSAGE,
static::FORMAT_PROCESSORS_DONE_MESSAGE,
count($occurrenceList->getOccurrences())
));
$this->finishProgressBar($processorsProgressBar, $output);
Expand Down Expand Up @@ -564,7 +564,7 @@ protected function traverseFiles(
$this->parseFiles($files, $traverser, $traverserProgressBar);

$traverserProgressBar->setMessage(sprintf(
self::FORMAT_VISITORS_DONE_MESSAGE,
static::FORMAT_VISITORS_DONE_MESSAGE,
count($files),
$traverser->getNodeOccurrencesCount()
));
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Application extends BaseApplication
private const APPLICATION_NAME = 'php-analyzer';

/** @var string */
private const APPLICATION_VERSION = '1.2.4';
private const APPLICATION_VERSION = '1.2.5';

/** @var string */
private const ARGUMENT_HELP = 'help';
Expand Down
12 changes: 12 additions & 0 deletions src/Console/Command/MagicNumberDetectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ class MagicNumberDetectorCommand extends AbstractCommand
/** @var string */
private const DEFAULT_VISITORS = 'Argument,Array,Assign,Condition,DefaultParameter,Operation,Property,Return,SwitchCase,Ternary'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
protected const FORMAT_PROCESSORS_DONE_MESSAGE = 'Processors processed magic numbers. Magic numbers found: %d';

/** @var string */
protected const FORMAT_PROCESSORS_PROGRESS_MESSAGE = 'Processor %d is processing magic numbers. Magic numbers found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
protected const FORMAT_VISITORS_DONE_MESSAGE = 'Visitors checked magic numbers in %d files. Magic numbers found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
protected const FORMAT_VISITORS_PROGRESS_MESSAGE = 'Visitors are checking for magic numbers in files. Magic numbers found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
private const HEADER_NUMBER = 'Number';

Expand Down
12 changes: 12 additions & 0 deletions src/Console/Command/MagicStringDetectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ class MagicStringDetectorCommand extends AbstractCommand
/** @var string */
private const DEFAULT_VISITORS = 'Argument,Array,Assign,Condition,DefaultParameter,Operation,Property,Return,SwitchCase,Ternary'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
protected const FORMAT_PROCESSORS_DONE_MESSAGE = 'Processors processed magic strings. Magic strings found: %d';

/** @var string */
protected const FORMAT_PROCESSORS_PROGRESS_MESSAGE = 'Processor %d is processing magic strings. Magic strings found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
protected const FORMAT_VISITORS_DONE_MESSAGE = 'Visitors checked magic strings in %d files. Magic strings found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
protected const FORMAT_VISITORS_PROGRESS_MESSAGE = 'Visitors are checking for magic strings in files. Magic strings found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
private const HEADER_OCCURRENCE = 'Occurrence';

Expand Down
12 changes: 12 additions & 0 deletions src/Console/Command/MostUsedConditionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ class MostUsedConditionsCommand extends AbstractCommand
/** @var string */
private const FORMAT_OCCURRENCE = '%s <flag>%s</flag><special-info>%s</special-info>';

/** @var string */
protected const FORMAT_PROCESSORS_DONE_MESSAGE = 'Processors processed conditions. Conditions found: %d';

/** @var string */
protected const FORMAT_PROCESSORS_PROGRESS_MESSAGE = 'Processor %d is processing conditions. Conditions found: %d'; //phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
private const FORMAT_TABLE_INFO_MAX_ENTRIES = '<info>Showing maximum %d conditions.</info>';

Expand All @@ -132,6 +138,12 @@ class MostUsedConditionsCommand extends AbstractCommand
/** @var string */
private const FORMAT_TABLE_INFO_SORT_BY = '<info>Sort Conditions by number of occurrences %s.</info>';

/** @var string */
protected const FORMAT_VISITORS_DONE_MESSAGE = 'Visitors checked conditions in %d files. Conditions found: %d'; //phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
protected const FORMAT_VISITORS_PROGRESS_MESSAGE = 'Visitors are checking for conditions in files. Conditions found: %d'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded

/** @var string */
private const HEADER_CONDITION = 'Condition';

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Console/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class ApplicationTest extends TestCase
{
/** @var string */
private const APPLICATION_INFO = 'php-analyzer 1.2.4 by Christopher Stenke <chris@isfett.com>' . \PHP_EOL;
private const APPLICATION_INFO = 'php-analyzer 1.2.5 by Christopher Stenke <chris@isfett.com>' . \PHP_EOL;

/** @var Application */
private $application;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function testRun(): void
'<command-start>Starting magic-number-detector command</command-start>',
$outputText
);
$this->assertStringContainsString('Processors processed magic numbers. Magic numbers found:', $outputText);

$expectedOutput = <<<EOT
+--------------------------------------------------------------+----------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function testRun(): void
'<command-start>Starting magic-string-detector command</command-start>',
$outputText
);
$this->assertStringContainsString('Processors processed magic strings. Magic strings found:', $outputText);

$expectedOutput = <<<EOT
+--------------------------------------------------------------+----------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function testRun(): void
'<command-start>Starting most-used-conditions command</command-start>',
$outputText
);
$this->assertStringContainsString('Processors processed conditions. Conditions found:', $outputText);

$expectedOutput = <<<EOT
+-----------------------------------------------------------------------------------------------------------------------------------------+-------+
Expand Down

0 comments on commit 7dc70bd

Please sign in to comment.