Skip to content

Commit

Permalink
Removed outdated format 'Devoops'
Browse files Browse the repository at this point in the history
  • Loading branch information
dseguy committed Feb 19, 2018
1 parent 1f55eb7 commit ff37b1b
Show file tree
Hide file tree
Showing 658 changed files with 82 additions and 183,714 deletions.
17 changes: 17 additions & 0 deletions human/en/Structures/PossibleInfiniteLoop.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name = "Possible Infinite Loop";
description = "Loops on files that can't be open results in infinite loop.
<?php
$file = fopen('/path/to/file.txt', 'r');
// when fopen() fails, the next loops is infinite
// fgets() will always return false, and while will always be true.
while($line = fgets($file) != '') {
doSomething();
}
?>
";
clearphp = "";
exakatSince = "1.1.5";
61 changes: 61 additions & 0 deletions library/Exakat/Analyzer/Structures/PossibleInfiniteLoop.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/*
* Copyright 2012-2018 Damien Seguy – Exakat Ltd <contact(at)exakat.io>
* This file is part of Exakat.
*
* Exakat is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Exakat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Exakat. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://exakat.io/>.
*
*/

namespace Exakat\Analyzer\Structures;

use Exakat\Analyzer\Analyzer;

class PossibleInfiniteLoop extends Analyzer {
public function analyze() {
$readFunctions = array('\fgets', '\fgetc', '\fgetss', '\fgetcsv');

//while($line = fgets($fp1) != 'a') {}
$this->atomIs(array('While', 'Dowhile'))
->outIs('CONDITION')
->outIsIE(array('LEFT', 'RIGHT')) // outIsIE goes directly to the comparison operands
->functioncallIs($readFunctions)
->inIs(array('LEFT', 'RIGHT'))
->atomIs('Comparison')
->codeIs('!=')
->outIs(array('LEFT', 'RIGHT'))
->isLiteral()
->is('boolean', true)
->back('first');
$this->prepareQuery();

//while($line = fgets($fp1) != 'a') {}
$this->atomIs('While')
->outIs('CONDITION')
->outIsIE(array('LEFT', 'RIGHT')) // outIsIE goes directly to the comparison operands
->functioncallIs($readFunctions)
->inIs(array('LEFT', 'RIGHT'))
->atomIs('Comparison')
->codeIs('!=')
->outIs(array('LEFT', 'RIGHT'))
->isLiteral()
->is('boolean', true)
->back('first');
$this->prepareQuery();
}
}

?>
2 changes: 1 addition & 1 deletion library/Exakat/Reports/Ambassador.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function generate($folder, $name = 'report') {

protected function initFolder() {
if ($this->finalName === null) {
return "Can't produce Devoops format to stdout";
return "Can't produce Ambassador format to stdout";
}

// Clean temporary destination
Expand Down
Loading

0 comments on commit ff37b1b

Please sign in to comment.