aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-cli/pom.xml
Commit message (Expand)AuthorAgeFilesLines
* [MRM-1111] upgrade to Struts 2.1.8.1Brett Porter2011-04-121-1/+1
* analyze dependenciesBrett Porter2010-03-101-2/+22
* merged recent changes from trunk, and reimplemented incoming audit log functi...Brett Porter2010-01-191-4/+3
|\
| * [maven-release-plugin] prepare for next development iterationBrett Porter2010-01-131-2/+2
| * [maven-release-plugin] prepare release archiva-1.3Brett Porter2010-01-131-2/+2
* | Merged /archiva/trunk:r883982-885005Brett Porter2009-11-271-1/+1
|\|
| * upgrade to Shade 1.2.2 so that build works with Maven 3.xBrett Porter2009-11-261-1/+1
* | [MRM-1025] merge -r721944:723577 from former MRM-1025 branch, now aligned to ...Brett Porter2009-10-161-2/+8
|/
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2009-08-271-2/+2
* [maven-release-plugin] prepare release archiva-1.2.2Maria Odea B. Ching2009-08-271-2/+2
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2009-08-241-2/+2
* [maven-release-plugin] prepare release archiva-1.2.2Maria Odea B. Ching2009-08-241-2/+2
* [MRM-1141] archiva-cli no longer worksMaria Odea B. Ching2009-07-301-1/+3
* [MRM-1141] archiva-cli no longer worksMaria Odea B. Ching2009-07-291-1/+4
* [MRM-1219] correct log4j configuration, consolidate logging APIsBrett Porter2009-07-161-1/+1
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2009-05-241-2/+2
* [maven-release-plugin] prepare release archiva-1.2.1Maria Odea B. Ching2009-05-241-2/+2
* revert to 1.2.1-SNAPSHOTMaria Odea B. Ching2009-05-241-2/+2
* [maven-release-plugin] prepare release archiva-1.2.1Maria Odea B. Ching2009-05-241-2/+2
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2009-03-221-2/+2
* [maven-release-plugin] prepare release archiva-1.2Maria Odea B. Ching2009-03-221-2/+2
* revert shade plugin version to previous oneBrett Porter2009-03-171-1/+1
* [MRM-1140] centralise logging through slf4jBrett Porter2009-03-141-6/+17
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2008-11-071-2/+2
* [maven-release-plugin] prepare release archiva-1.2-M1Maria Odea B. Ching2008-11-071-2/+2
* add required JAR for CLI executionBrett Porter2008-08-071-0/+4
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2008-07-161-2/+2
* [maven-release-plugin] prepare release archiva-1.1Maria Odea B. Ching2008-07-161-2/+2
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2008-07-081-2/+2
* [maven-release-plugin] prepare release archiva-1.1Maria Odea B. Ching2008-07-081-2/+2
* MRM-855 - java.lang.NoClassDefFoundError: org/apache/xml/serialize/OutputFormatJames William Dumay2008-07-021-0/+1
* POM clean upBrett Porter2008-06-141-3/+0
* -exclude commons-io which is causing a conflictMaria Odea B. Ching2008-04-161-0/+1
* -reverted exclusions of plexus-container in plexus-spring dependencyMaria Odea B. Ching2008-04-151-6/+0
* -exclude plexus container in plexus-spring dependencyMaria Odea B. Ching2008-04-141-0/+6
* clean up dependenciesBrett Porter2008-04-091-0/+4
* a couple of workarounds to force "offline" behaviourBrett Porter2008-04-081-0/+5
* refreshed the CLIBrett Porter2008-04-071-41/+41
* change the group IDBrett Porter2008-03-291-4/+4
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2008-01-171-2/+2
* [maven-release-plugin] prepare release archiva-1.0.1Maria Odea B. Ching2008-01-171-1/+2
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2007-11-231-1/+1
* [maven-release-plugin] prepare release archiva-1.0Maria Odea B. Ching2007-11-231-1/+1
* lining up to a common parent called "archiva" instead, incorparating site, pr...Brett Porter2007-11-111-1/+1
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2007-11-091-1/+1
* [maven-release-plugin] prepare release archiva-1.0-beta-4Maria Odea B. Ching2007-11-091-1/+1
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2007-10-301-1/+1
* [maven-release-plugin] prepare release archiva-1.0-beta-3Maria Odea B. Ching2007-10-301-1/+1
* -Reverted version to 1.0-beta-3-SNAPSHOTMaria Odea B. Ching2007-10-261-1/+1
* [maven-release-plugin] prepare for next development iterationMaria Odea B. Ching2007-10-221-1/+1
on> Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/build/OCPSinceChecker.php
blob: 04a19b3416f5486e8a9cd6a6a705378a52d8a966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
 * @author Morris Jobke <hey@morrisjobke.de>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */


require_once(dirname(__DIR__) . '/3rdparty/autoload.php');

/**
 * Class SinceTagCheckVisitor
 *
 * this class checks all methods for the presence of the @since tag
 */
class SinceTagCheckVisitor extends \PhpParser\NodeVisitorAbstract {

	/** @var string */
	protected $namespace = '';
	/** @var string */
	protected $className = '';
	/** @var bool */
	protected $deprecatedClass = false;

	/** @var array */
	protected $errors = [];

	public function enterNode(\PhpParser\Node $node) {
		if($this->deprecatedClass) {
			return;
		}

		if($node instanceof \PhpParser\Node\Stmt\Namespace_) {
			$this->namespace = $node->name;
		}

		if($node instanceof \PhpParser\Node\Stmt\Interface_ or
			$node instanceof \PhpParser\Node\Stmt\Class_) {
			$this->className = $node->name;

			/** @var \PhpParser\Comment\Doc[] $comments */
			$comments = $node->getAttribute('comments');

			if(count($comments) === 0) {
				$this->errors[] = 'PHPDoc is needed for ' . $this->namespace . '\\' . $this->className . '::' . $node->name;
				return;
			}

			$comment = $comments[count($comments) - 1];
			$text = $comment->getText();
			if(strpos($text, '@deprecated') !== false) {
				$this->deprecatedClass = true;
			}

			if($this->deprecatedClass === false && strpos($text, '@since') === false && strpos($text, '@deprecated') === false) {
				$type = $node instanceof \PhpParser\Node\Stmt\Interface_ ? 'interface' : 'class';
				$this->errors[] = '@since or @deprecated tag is needed in PHPDoc for ' . $type . ' ' . $this->namespace . '\\' . $this->className;
				return;
			}
		}

		if($node instanceof \PhpParser\Node\Stmt\ClassMethod) {
			/** @var \PhpParser\Node\Stmt\ClassMethod $node */
			/** @var \PhpParser\Comment\Doc[] $comments */
			$comments = $node->getAttribute('comments');

			if(count($comments) === 0) {
				$this->errors[] = 'PHPDoc is needed for ' . $this->namespace . '\\' . $this->className . '::' . $node->name;
				return;
			}
			$comment = $comments[count($comments) - 1];
			$text = $comment->getText();
			if(strpos($text, '@since') === false && strpos($text, '@deprecated') === false) {
				$this->errors[] = '@since or @deprecated tag is needed in PHPDoc for ' . $this->namespace . '\\' . $this->className . '::' . $node->name;
				return;
			}
		}
	}

	public function getErrors() {
		return $this->errors;
	}
}

echo 'Parsing all files in lib/public for the presence of @since or @deprecated on each method...' . PHP_EOL . PHP_EOL;


$parser = new PhpParser\Parser(new PhpParser\Lexer);

/* iterate over all .php files in lib/public */
$Directory = new RecursiveDirectoryIterator(dirname(__DIR__) . '/lib/public');
$Iterator = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($Iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);

$errors = [];

foreach($Regex as $file) {
	$stmts = $parser->parse(file_get_contents($file[0]));

	$visitor = new SinceTagCheckVisitor();
	$traverser = new \PhpParser\NodeTraverser();
	$traverser->addVisitor($visitor);
	$traverser->traverse($stmts);

	$errors = array_merge($errors, $visitor->getErrors());
}

if(count($errors)) {
	echo join(PHP_EOL, $errors) . PHP_EOL . PHP_EOL;
	exit(1);
}