Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
Adjust code for the loaders
change quotes
  • Loading branch information
exussum12 committed Jan 6, 2017
1 parent d6de4bc commit 84b5f37
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ With composer simply
then call the script you need

##Manually
Clone this repository somewhere your your build plan can be accessed, composer install (required for the class loader only)
Clone this repository somewhere your your build plan can be accessed, composer install is prefered but there is a non composer class loader which will be used if composer is not installed.
Then call the script you need


Expand All @@ -40,7 +40,7 @@ exit code 0 and no output indicates success

php vendor/bin/phpunitDiffFilter /tmp/diff.txt report/coverage.xml 90

Will fail (exit status 1) if less than 90% of the code committed is covered by a test.
Will fail (exit status 2) if less than 90% of the code committed is covered by a test.
This requires phpunit to be run on the branch first!

##phpcs
Expand All @@ -51,7 +51,7 @@ All of the commands can read from stdin with placeholder `-`

phpcs can be run with any options you normally have for example `--standard=PSR2`

This will exit with code 1 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.
This will exit with code 2 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.


##phpmd
Expand All @@ -62,4 +62,4 @@ All of the commands can read from stdin with placeholder `-`

phpcs can be run with any options you normally have for example `cleancode,codesize,controversial`

This will exit with code 1 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.
This will exit with code 2 if any of the new/edited code fails the code standards check. The output is kept so you can see what the offending lines are and what the error is.
24 changes: 21 additions & 3 deletions bin/phpcsDiffFilter
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#!/usr/bin/env php
<?php
$locations = [
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../autoload.php'
];

foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
$found = false;

foreach ($locations as $file) {
if (file_exists($file)) {
require_once($file);

$found = true;
break;
}
}

if (!$found) {
error_log(
"Can't find the autoload file," .
"please make sure 'composer install' has been run"
);

exit(1);
}

if (!isset($argv[1], $argv[2])) {
echo "Missing arguments, please call with diff and check file" . PHP_EOL;
error_log(
"Missing arguments, please call with diff and check file"
);
exit(1);
}

Expand Down
24 changes: 21 additions & 3 deletions bin/phpmdDiffFilter
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#!/usr/bin/env php
<?php
$locations = [
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../autoload.php'
];

foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
$found = false;

foreach ($locations as $file) {
if (file_exists($file)) {
require_once($file);

$found = true;
break;
}
}

if (!$found) {
error_log(
"Can't find the autoload file," .
"please make sure 'composer install' has been run"
);

exit(1);
}

if (!isset($argv[1], $argv[2])) {
echo "Missing arguments, please call with diff and check file" . PHP_EOL;
error_log(
"Missing arguments, please call with diff and check file"
);
exit(1);
}

Expand Down
24 changes: 21 additions & 3 deletions bin/phpunitDiffFilter
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#!/usr/bin/env php
<?php
$locations = [
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../autoload.php'
];

foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
$found = false;

foreach ($locations as $file) {
if (file_exists($file)) {
require_once($file);

$found = true;
break;
}
}

if (!$found) {
error_log(
"Can't find the autoload file," .
"please make sure 'composer install' has been run"
);

exit(1);
}

if (!isset($argv[1], $argv[2])) {
echo "Missing arguments, please call with diff and check file" . PHP_EOL;
error_log(
"Missing arguments, please call with diff and check file"
);
exit(1);
}

Expand Down
7 changes: 4 additions & 3 deletions src/DiffFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ public function __construct($fileName)
{
$this->fileLocation = $fileName;
$this->diff = new DiffFileState();

}

public function getChangedLines()
{
$handle = @fopen($this->fileLocation, "r");

if (!$handle) {
if (!is_readable($this->fileLocation)) {
throw new InvalidArgumentException("Can't read file");
}

$handle = fopen($this->fileLocation, 'r');

while (($line = fgets($handle)) !== false) {
// process the line read.
$lineHandle = $this->getLineHandle($line);
Expand Down
8 changes: 4 additions & 4 deletions tests/DiffFileLoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ public function getResults()
{
return [
'newFile' => [
__DIR__ . "/fixtures/newFile.txt",
__DIR__ . '/fixtures/newFile.txt',
[
'changedFile.php' => [1,2,3]
]
],
'lineChange' => [
__DIR__ . "/fixtures/change.txt",
__DIR__ . '/fixtures/change.txt',
[
'changedFile.php' => [3]
]
],
'multipleFiles' => [
__DIR__ . "/fixtures/multiple.txt",
__DIR__ . '/fixtures/multiple.txt',
[
'changedFile.php' => [3],
'newFile.php' => [1,2,3]
]
],
'removeFile' => [
__DIR__ . "/fixtures/removeFile.txt",
__DIR__ . '/fixtures/removeFile.txt',
[]
],
];
Expand Down

0 comments on commit 84b5f37

Please sign in to comment.