Browse Source

update phpmd ruleset to use (subset) of cleancode
fix various minor issues reported by static analysis
remove redundant php closing tag from several more files

Andrew Dolgov 3 years ago
parent
commit
21ce7d9ec0
53 changed files with 138 additions and 173 deletions
  1. 2 3
      plugins/af_comics/af_comics_template.php
  2. 1 2
      plugins/af_comics/filter_base.php
  3. 2 8
      plugins/af_comics/filters/af_comics_cad.php
  4. 2 8
      plugins/af_comics/filters/af_comics_comicclass.php
  5. 2 8
      plugins/af_comics/filters/af_comics_comicpress.php
  6. 2 7
      plugins/af_comics/filters/af_comics_darklegacy.php
  7. 1 21
      plugins/af_comics/filters/af_comics_dilbert.php
  8. 2 7
      plugins/af_comics/filters/af_comics_explosm.php
  9. 7 12
      plugins/af_comics/filters/af_comics_pa.php
  10. 2 4
      plugins/af_comics/filters/af_comics_pvp.php
  11. 2 6
      plugins/af_comics/filters/af_comics_tfd.php
  12. 2 6
      plugins/af_comics/filters/af_comics_twp.php
  13. 1 2
      plugins/af_comics/filters/af_comics_whomp.php
  14. 4 5
      plugins/af_comics/init.php
  15. 1 2
      plugins/af_fsckportal/init.php
  16. 0 1
      plugins/af_lang_detect/init.php
  17. 2 2
      plugins/af_lang_detect/languagedetect/LanguageDetect.php
  18. 2 2
      plugins/af_lang_detect/languagedetect/Text/LanguageDetect/ISO639.php
  19. 0 2
      plugins/af_lang_detect/languagedetect/Text/LanguageDetect/Parser.php
  20. 1 2
      plugins/af_psql_trgm/init.php
  21. 4 2
      plugins/af_readability/init.php
  22. 7 2
      plugins/af_redditimgur/init.php
  23. 1 2
      plugins/af_tumblr_1280/init.php
  24. 1 2
      plugins/af_unburn/init.php
  25. 3 1
      plugins/af_youtube_embed/init.php
  26. 4 1
      plugins/af_zz_imgproxy/init.php
  27. 1 2
      plugins/af_zz_imgsetsizes/init.php
  28. 1 2
      plugins/af_zz_noautoplay/init.php
  29. 1 2
      plugins/af_zz_vidmute/init.php
  30. 3 4
      plugins/auth_remote/init.php
  31. 1 2
      plugins/auto_assign_labels/init.php
  32. 1 2
      plugins/bookmarklets/init.php
  33. 15 1
      plugins/cache_starred_images/init.php
  34. 4 2
      plugins/close_button/init.php
  35. 1 2
      plugins/embed_original/init.php
  36. 1 2
      plugins/googlereaderkeys/init.php
  37. 7 2
      plugins/import_export/init.php
  38. 10 2
      plugins/instances/init.php
  39. 1 2
      plugins/mail/init.php
  40. 1 3
      plugins/mailto/init.php
  41. 0 1
      plugins/mark_button/init.php
  42. 4 2
      plugins/no_iframes/init.php
  43. 1 2
      plugins/no_title_counters/init.php
  44. 1 2
      plugins/no_url_hashes/init.php
  45. 1 2
      plugins/note/init.php
  46. 1 2
      plugins/nsfw/init.php
  47. 1 2
      plugins/search_sphinx/init.php
  48. 4 0
      plugins/search_sphinx/sphinxapi.php
  49. 2 4
      plugins/share/init.php
  50. 1 2
      plugins/shorten_expanded/init.php
  51. 1 2
      plugins/swap_jk/init.php
  52. 10 2
      plugins/vf_shared/init.php
  53. 5 0
      utils/gitlab-ci/phpmd-ruleset.xml

+ 2 - 3
plugins/af_comics/af_comics_template.php

@@ -6,9 +6,8 @@ class Af_Comics_Template extends Af_ComicFilter {
 	}
 
 	function process(&$article) {
-		$owner_uid = $article["owner_uid"];
+		//$owner_uid = $article["owner_uid"];
 
 		return false;
 	}
-}
-?>
+}

+ 1 - 2
plugins/af_comics/filter_base.php

@@ -2,5 +2,4 @@
 abstract class Af_ComicFilter {
 	public abstract function supported();
 	public abstract function process(&$article);
-}
-?>
+}

+ 2 - 8
plugins/af_comics/filters/af_comics_cad.php

@@ -6,17 +6,12 @@ class Af_Comics_Cad extends Af_ComicFilter {
 	}
 
 	function process(&$article) {
-		$owner_uid = $article["owner_uid"];
-
 		if (strpos($article["link"], "cad-comic.com/cad/") !== FALSE) {
 			if (strpos($article["title"], "News:") === FALSE) {
 
 				$doc = new DOMDocument();
-				@$doc->loadHTML(fetch_file_contents($article["link"]));
-
-				$basenode = false;
 
-				if ($doc) {
+				if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
 					$xpath = new DOMXPath($doc);
 					$basenode = $xpath->query('(//img[contains(@src, "/comics/cad-")])')->item(0);
 
@@ -32,5 +27,4 @@ class Af_Comics_Cad extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 2 - 8
plugins/af_comics/filters/af_comics_comicclass.php

@@ -6,8 +6,6 @@ class Af_Comics_ComicClass extends Af_ComicFilter {
 	}
 
 	function process(&$article) {
-		$owner_uid = $article["owner_uid"];
-
 		if (strpos($article["guid"], "loadingartist.com") !== FALSE) {
 
 				// lol at people who block clients by user agent
@@ -18,11 +16,8 @@ class Af_Comics_ComicClass extends Af_ComicFilter {
 					 "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
 
 				$doc = new DOMDocument();
-				@$doc->loadHTML($res);
-
-				$basenode = false;
 
-				if ($doc) {
+				if (@$doc->loadHTML($res)) {
 					$xpath = new DOMXPath($doc);
 					$basenode = $xpath->query('//div[@class="comic"]')->item(0);
 
@@ -36,5 +31,4 @@ class Af_Comics_ComicClass extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 2 - 8
plugins/af_comics/filters/af_comics_comicpress.php

@@ -7,8 +7,6 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
 	}
 
 	function process(&$article) {
-		$owner_uid = $article["owner_uid"];
-
 		if (strpos($article["guid"], "bunicomic.com") !== FALSE ||
 				strpos($article["guid"], "buttersafe.com") !== FALSE ||
 				strpos($article["guid"], "extrafabulouscomics.com") !== FALSE ||
@@ -23,11 +21,8 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
 					 "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
 
 				$doc = new DOMDocument();
-				@$doc->loadHTML($res);
-
-				$basenode = false;
 
-				if ($doc) {
+				if (@$doc->loadHTML($res)) {
 					$xpath = new DOMXPath($doc);
 					$basenode = $xpath->query('//div[@id="comic"]')->item(0);
 
@@ -41,5 +36,4 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 2 - 7
plugins/af_comics/filters/af_comics_darklegacy.php

@@ -6,7 +6,6 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
 	}
 
 	function process(&$article) {
-		$owner_uid = $article["owner_uid"];
 
 		if (strpos($article["guid"], "darklegacycomics.com") !== FALSE) {
 
@@ -20,11 +19,8 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
 					$res = $fetch_last_error_content;
 
 				$doc = new DOMDocument();
-				@$doc->loadHTML($res);
 
-				$basenode = false;
-
-				if ($doc) {
+				if (@$doc->loadHTML($res)) {
 					$xpath = new DOMXPath($doc);
 					$basenode = $xpath->query('//div[@class="comic"]')->item(0);
 
@@ -39,5 +35,4 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 1 - 21
plugins/af_comics/filters/af_comics_dilbert.php

@@ -19,30 +19,11 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
 				$doc = new DOMDocument();
 				@$doc->loadHTML($res);
 
-				$basenode = false;
-
 				if ($doc) {
 					$xpath = new DOMXPath($doc);
 
 					$basenode = $xpath->query('//img[contains(@class, "img-comic")]')->item(0);
 
-					/* $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
-
-					$matches = array();
-
-					foreach ($entries as $entry) {
-
-						if (preg_match("/dyn\/str_strip\/.*strip\.gif$/", $entry->getAttribute("src"), $matches)) {
-
-							$entry->setAttribute("src",
-								rewrite_relative_url("http://dilbert.com/",
-								$matches[0]));
-
-							$basenode = $entry;
-							break;
-						}
-					} */
-
 					if ($basenode) {
 						$article["content"] = $doc->saveXML($basenode);
 					}
@@ -53,5 +34,4 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 2 - 7
plugins/af_comics/filters/af_comics_explosm.php

@@ -6,16 +6,12 @@ class Af_Comics_Explosm extends Af_ComicFilter {
 	}
 
 	function process(&$article) {
-		$owner_uid = $article["owner_uid"];
 
 		if (strpos($article["link"], "explosm.net/comics") !== FALSE) {
 
 				$doc = new DOMDocument();
-				@$doc->loadHTML(fetch_file_contents($article["link"]));
 
-				$basenode = false;
-
-				if ($doc) {
+				if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
 					$xpath = new DOMXPath($doc);
 					$basenode = $xpath->query('(//img[@id="main-comic"])')->item(0);
 
@@ -29,5 +25,4 @@ class Af_Comics_Explosm extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 7 - 12
plugins/af_comics/filters/af_comics_pa.php

@@ -8,16 +8,13 @@ class Af_Comics_Pa extends Af_ComicFilter {
 	function process(&$article) {
 		if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
 
-				if ($debug_enabled) {
+				/*if ($debug_enabled) {
 					_debug("af_pennyarcade: Processing comic");
-				}
+				}*/
 
 				$doc = new DOMDocument();
-				$doc->loadHTML(fetch_file_contents($article["link"]));
-
-				$basenode = false;
 
-				if ($doc) {
+				if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
 					$xpath = new DOMXPath($doc);
 					$basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0);
 
@@ -30,13 +27,12 @@ class Af_Comics_Pa extends Af_ComicFilter {
 		}
 
 		if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
-				if ($debug_enabled) {
+				/*if ($debug_enabled) {
 					_debug("af_pennyarcade: Processing news post");
-				}
+				}*/
 				$doc = new DOMDocument();
-				$doc->loadHTML(fetch_file_contents($article["link"]));
 
-				if ($doc) {
+				if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
 					$xpath = new DOMXPath($doc);
 					$entries = $xpath->query('(//div[@class="post"])');
 
@@ -75,5 +71,4 @@ class Af_Comics_Pa extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 2 - 4
plugins/af_comics/filters/af_comics_pvp.php

@@ -13,9 +13,8 @@ class Af_Comics_Pvp extends Af_ComicFilter {
 					 "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
 
 				$doc = new DOMDocument();
-				@$doc->loadHTML($res);
 
-				if ($doc) {
+				if (@$doc->loadHTML($res)) {
 					$xpath = new DOMXPath($doc);
 					$basenode = $xpath->query('//section[@class="comic-art"]')->item(0);
 
@@ -29,5 +28,4 @@ class Af_Comics_Pvp extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 2 - 6
plugins/af_comics/filters/af_comics_tfd.php

@@ -15,11 +15,8 @@ class Af_Comics_Tfd extends Af_ComicFilter {
 			if (!$res) return $article;
 
 			$doc = new DOMDocument();
-			@$doc->loadHTML(fetch_file_contents($article["link"]));
-			
-			$basenode = false;
 
-			if ($doc) {
+			if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
 				$xpath = new DOMXPath($doc);
 				$basenode = $xpath->query('//img[contains(@src, ".gif")]')->item(0);
 
@@ -32,5 +29,4 @@ class Af_Comics_Tfd extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 2 - 6
plugins/af_comics/filters/af_comics_twp.php

@@ -10,11 +10,8 @@ class Af_Comics_Twp extends Af_ComicFilter {
 		if (strpos($article["link"], "threewordphrase.com") !== FALSE) {
 
 				$doc = new DOMDocument();
-				@$doc->loadHTML(fetch_file_contents($article["link"]));
 
-				$basenode = false;
-
-				if ($doc) {
+				if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
 					$xpath = new DOMXpath($doc);
 
 					$basenode = $xpath->query("//td/center/img")->item(0);
@@ -29,5 +26,4 @@ class Af_Comics_Twp extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 1 - 2
plugins/af_comics/filters/af_comics_whomp.php

@@ -33,5 +33,4 @@ class Af_Comics_Whomp extends Af_ComicFilter {
 
 		return false;
 	}
-}
-?>
+}

+ 4 - 5
plugins/af_comics/init.php

@@ -63,18 +63,18 @@ class Af_Comics extends Plugin {
 	}
 
 	function hook_article_filter($article) {
-		$owner_uid = $article["owner_uid"];
-
 		foreach ($this->filters as $f) {
 			if ($f->process($article))
 				break;
 		}
 
 		return $article;
-
 	}
 
 	// GoComics dropped feed support so it needs to be handled when fetching the feed.
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) {
 		if ($auth_login || $auth_pass)
 			return $feed_data;
@@ -143,5 +143,4 @@ class Af_Comics extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/af_fsckportal/init.php

@@ -48,5 +48,4 @@ class Af_Fsckportal extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 0 - 1
plugins/af_lang_detect/init.php

@@ -43,4 +43,3 @@ class Af_Lang_Detect extends Plugin {
 	}
 
 }
-?>

+ 2 - 2
plugins/af_lang_detect/languagedetect/LanguageDetect.php

@@ -64,6 +64,8 @@ require_once __DIR__ . '/Text/LanguageDetect/ISO639.php';
  * @version   Release: @[email protected]
  * @link      http://pear.php.net/package/Text_LanguageDetect/
  * @todo      allow users to generate their own language models
+ *
+ * @SuppressWarnings(PHPMD)
  */
 class Text_LanguageDetect
 {
@@ -1704,5 +1706,3 @@ class Text_LanguageDetect
 }
 
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-?>

+ 2 - 2
plugins/af_lang_detect/languagedetect/Text/LanguageDetect/ISO639.php

@@ -25,6 +25,8 @@
  * @copyright 2011 Christian Weiske <[email protected]>
  * @license   http://www.debian.org/misc/bsd.license BSD
  * @link      http://www.loc.gov/standards/iso639-2/php/code_list.php
+ *
+ * @SuppressWarnings(PHPMD)
  */
 class Text_LanguageDetect_ISO639
 {
@@ -337,5 +339,3 @@ class Text_LanguageDetect_ISO639
         return self::$code3ToName[$code];
     }
 }
-
-?>

+ 0 - 2
plugins/af_lang_detect/languagedetect/Text/LanguageDetect/Parser.php

@@ -345,5 +345,3 @@ class Text_LanguageDetect_Parser extends Text_LanguageDetect
 }
 
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-?>

+ 1 - 2
plugins/af_psql_trgm/init.php

@@ -321,5 +321,4 @@ class Af_Psql_Trgm extends Plugin {
 		return $tmp;
 	}
 
-}
-?>
+}

+ 4 - 2
plugins/af_readability/init.php

@@ -128,6 +128,9 @@ class Af_Readability extends Plugin {
 		$this->host->set($this, "enabled_feeds", $enabled_feeds);
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_article_filter_action($article, $action) {
 		return $this->process_article($article);
 	}
@@ -146,7 +149,7 @@ class Af_Readability extends Plugin {
 			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 			curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
 
-			@$result = curl_exec($ch);
+			@curl_exec($ch);
 			$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
 
 			if (strpos($content_type, "text/html") === FALSE)
@@ -243,4 +246,3 @@ class Af_Readability extends Plugin {
 	}
 
 }
-?>

+ 7 - 2
plugins/af_redditimgur/init.php

@@ -73,6 +73,9 @@ class Af_RedditImgur extends Plugin {
 		echo __("Configuration saved");
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	private function inline_stuff($article, &$doc, $xpath, $debug = false) {
 
 		$entries = $xpath->query('(//a[@href]|//img[@src])');
@@ -442,13 +445,16 @@ class Af_RedditImgur extends Plugin {
 			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
 
-			@$result = curl_exec($ch);
+			@curl_exec($ch);
 			$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
 		}
 
 		return $content_type;
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	private function readability($article, $url, $doc, $xpath, $debug = false) {
 
 		if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") &&
@@ -510,4 +516,3 @@ class Af_RedditImgur extends Plugin {
 		return $article;
 	}
 }
-?>

+ 1 - 2
plugins/af_tumblr_1280/init.php

@@ -79,5 +79,4 @@ class Af_Tumblr_1280 extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/af_unburn/init.php

@@ -81,5 +81,4 @@ class Af_Unburn extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 3 - 1
plugins/af_youtube_embed/init.php

@@ -14,6 +14,9 @@ class Af_Youtube_Embed extends Plugin {
 		$host->add_hook($host::HOOK_RENDER_ENCLOSURE, $this);
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_render_enclosure($entry, $hide_images) {
 
 		$matches = array();
@@ -37,4 +40,3 @@ class Af_Youtube_Embed extends Plugin {
 	}
 
 }
-?>

+ 4 - 1
plugins/af_zz_imgproxy/init.php

@@ -80,7 +80,7 @@ class Af_Zz_ImgProxy extends Plugin {
 				if (function_exists("imagecreate") && !isset($_REQUEST["text"])) {
 					$img = imagecreate(450, 75);
 
-					$bg = imagecolorallocate($img, 255, 255, 255);
+					/*$bg =*/ imagecolorallocate($img, 255, 255, 255);
 					$textcolor = imagecolorallocate($img, 255, 0, 0);
 
 					imagerectangle($img, 0, 0, 450-1, 75-1, $textcolor);
@@ -143,6 +143,9 @@ class Af_Zz_ImgProxy extends Plugin {
 		return $url;
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_render_article_cdm($article, $api_mode = false) {
 
 		$need_saving = false;

+ 1 - 2
plugins/af_zz_imgsetsizes/init.php

@@ -89,5 +89,4 @@ class Af_Zz_ImgSetSizes extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/af_zz_noautoplay/init.php

@@ -20,5 +20,4 @@ class Af_Zz_NoAutoPlay extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/af_zz_vidmute/init.php

@@ -20,5 +20,4 @@ class Af_Zz_VidMute extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 3 - 4
plugins/auth_remote/init.php

@@ -34,7 +34,9 @@ class Auth_Remote extends Plugin implements IAuthModule {
 		return "";
 	}
 
-
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function authenticate($login, $password) {
 		$try_login = db_escape_string($_SERVER["REMOTE_USER"]);
 
@@ -43,7 +45,6 @@ class Auth_Remote extends Plugin implements IAuthModule {
 		if (!$try_login) $try_login = db_escape_string($_SERVER["PHP_AUTH_USER"]);
 
 		if (!$try_login) $try_login = $this->get_login_by_ssl_certificate();
-#	  	if (!$try_login) $try_login = "test_qqq";
 
 		if ($try_login) {
 			$user_id = $this->base->auto_create_user($try_login, $password);
@@ -84,5 +85,3 @@ class Auth_Remote extends Plugin implements IAuthModule {
 	}
 
 }
-
-?>

+ 1 - 2
plugins/auto_assign_labels/init.php

@@ -53,5 +53,4 @@ class Auto_Assign_Labels extends Plugin {
 	function api_version() {
 		return 2;
 	}
-}
-?>
+}

+ 1 - 2
plugins/bookmarklets/init.php

@@ -50,5 +50,4 @@ class Bookmarklets extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 15 - 1
plugins/cache_starred_images/init.php

@@ -11,10 +11,16 @@ class Cache_Starred_Images extends Plugin implements IHandler {
 			true);
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function csrf_ignore($method) {
 		return false;
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function before($method) {
 		return true;
 	}
@@ -88,6 +94,9 @@ class Cache_Starred_Images extends Plugin implements IHandler {
 		}
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedLocalVariable)
+	 */
 	function hook_house_keeping() {
 		$files = glob($this->cache_dir . "/*.{png,mp4}", GLOB_BRACE);
 
@@ -112,6 +121,9 @@ class Cache_Starred_Images extends Plugin implements IHandler {
 		}
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) {
 		$xpath = new DOMXpath($doc);
 
@@ -162,6 +174,9 @@ class Cache_Starred_Images extends Plugin implements IHandler {
 		}
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function cache_article_images($content, $site_url, $owner_uid, $article_id) {
 		libxml_use_internal_errors(true);
 
@@ -211,4 +226,3 @@ class Cache_Starred_Images extends Plugin implements IHandler {
 		return 2;
 	}
 }
-?>

+ 4 - 2
plugins/close_button/init.php

@@ -14,6 +14,9 @@ class Close_Button extends Plugin {
 			"fox");
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_article_button($line) {
 		if (!get_pref("COMBINED_DISPLAY_MODE")) {
 			$rv = "<img src=\"plugins/close_button/button.png\"
@@ -29,5 +32,4 @@ class Close_Button extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/embed_original/init.php

@@ -54,5 +54,4 @@ class Embed_Original extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/googlereaderkeys/init.php

@@ -37,5 +37,4 @@ class GoogleReaderKeys extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 7 - 2
plugins/import_export/init.php

@@ -91,6 +91,9 @@ class Import_Export extends Plugin implements IHandler {
 		return in_array($method, array("exportget"));
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function before($method) {
 		return $_SESSION["uid"] != false;
 	}
@@ -99,6 +102,9 @@ class Import_Export extends Plugin implements IHandler {
 		return true;
 	}
 
+	/**
+	 * @SuppressWarnings(unused)
+	 */
 	function exportget() {
 		$exportname = CACHE_DIR . "/export/" .
 			sha1($_SESSION['uid'] . $_SESSION['login']) . ".xml";
@@ -468,5 +474,4 @@ class Import_Export extends Plugin implements IHandler {
 		return 2;
 	}
 
-}
-?>
+}

+ 10 - 2
plugins/instances/init.php

@@ -25,6 +25,9 @@ class Instances extends Plugin implements IHandler {
 		$host->add_hook($host::HOOK_UPDATE_TASK, $this);
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_update_task($args) {
 		_debug("Get linked feeds...");
 		$this->get_linked_feeds();
@@ -134,6 +137,9 @@ class Instances extends Plugin implements IHandler {
 		return file_get_contents(dirname(__FILE__) . "/instances.js");
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_prefs_tabs($args) {
 		if ($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) {
 			?><div id="instanceConfigTab" dojoType="dijit.layout.ContentPane"
@@ -148,6 +154,9 @@ class Instances extends Plugin implements IHandler {
 		return array_search($method, $csrf_ignored) !== false;
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function before($method) {
 		if ($_SESSION["uid"]) {
 			if ($_SESSION["access_level"] < 10) {
@@ -171,7 +180,7 @@ class Instances extends Plugin implements IHandler {
 	}
 
 	function add() {
-		$id = db_escape_string($_REQUEST["id"]);
+		//$id = db_escape_string($_REQUEST["id"]);
 		$access_url = db_escape_string($_REQUEST["access_url"]);
 		$access_key = db_escape_string($_REQUEST["access_key"]);
 
@@ -449,4 +458,3 @@ class Instances extends Plugin implements IHandler {
 	}
 
 }
-?>

+ 1 - 2
plugins/mail/init.php

@@ -224,5 +224,4 @@ class Mail extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 3
plugins/mailto/init.php

@@ -32,12 +32,11 @@ class MailTo extends Plugin {
 		require_once "lib/MiniTemplator.class.php";
 
 		$tpl = new MiniTemplator;
-		$tpl_t = new MiniTemplator;
 
 		$tpl->readTemplateFromFile("templates/email_article_template.txt");
 
 		$tpl->setVariable('USER_NAME', $_SESSION["name"], true);
-		$tpl->setVariable('USER_EMAIL', $user_email, true);
+		//$tpl->setVariable('USER_EMAIL', $user_email, true);
 		$tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
 
 
@@ -91,4 +90,3 @@ class MailTo extends Plugin {
 	}
 
 }
-?>

+ 0 - 1
plugins/mark_button/init.php

@@ -40,4 +40,3 @@ class Mark_Button extends Plugin {
 	}
 
 }
-?>

+ 4 - 2
plugins/no_iframes/init.php

@@ -14,6 +14,9 @@ class No_Iframes extends Plugin {
 		$host->add_hook($host::HOOK_SANITIZE, $this);
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {
 
 		$xpath = new DOMXpath($doc);
@@ -31,5 +34,4 @@ class No_Iframes extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/no_title_counters/init.php

@@ -21,5 +21,4 @@ class No_Title_Counters extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/no_url_hashes/init.php

@@ -21,5 +21,4 @@ class No_URL_Hashes extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/note/init.php

@@ -72,5 +72,4 @@ class Note extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/nsfw/init.php

@@ -104,5 +104,4 @@ class NSFW extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/search_sphinx/init.php

@@ -61,5 +61,4 @@ class Search_Sphinx extends Plugin {
 	function api_version() {
 		return 2;
 	}
-}
-?>
+}

+ 4 - 0
plugins/search_sphinx/sphinxapi.php

@@ -973,6 +973,10 @@ class SphinxClient
 		return pack ( "N", $t2 );
 	}
 
+	/**
+	 * @SuppressWarnings(unused)
+	 */
+
 	/// add query to multi-query batch
 	/// returns index into results array from RunQueries() call
 	function AddQuery ( $query, $index="*", $comment="" )

+ 2 - 4
plugins/share/init.php

@@ -78,7 +78,7 @@ class Share extends Plugin {
 	function shareArticle() {
 		$param = db_escape_string($_REQUEST['param']);
 
-		$result = db_query("SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
+		$result = db_query("SELECT uuid FROM ttrss_user_entries WHERE int_id = '$param'
 			AND owner_uid = " . $_SESSION['uid']);
 
 		if (db_num_rows($result) == 0) {
@@ -86,7 +86,6 @@ class Share extends Plugin {
 		} else {
 
 			$uuid = db_fetch_result($result, 0, "uuid");
-			$ref_id = db_fetch_result($result, 0, "ref_id");
 
 			if (!$uuid) {
 				$uuid = db_escape_string(uniqid_short());
@@ -127,5 +126,4 @@ class Share extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/shorten_expanded/init.php

@@ -25,5 +25,4 @@ class Shorten_Expanded extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 1 - 2
plugins/swap_jk/init.php

@@ -27,5 +27,4 @@ class Swap_JK extends Plugin {
 		return 2;
 	}
 
-}
-?>
+}

+ 10 - 2
plugins/vf_shared/init.php

@@ -20,12 +20,18 @@ class VF_Shared extends Plugin {
 		return 2;
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function get_unread($feed_id) {
 		$result = db_query("select count(int_id) AS count from ttrss_user_entries where owner_uid = ".$_SESSION["uid"]." and unread = true and uuid != ''");
 
 		return db_fetch_result($result, 0, "count");
 	}
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function get_total($feed_id) {
 		$result = db_query("select count(int_id) AS count from ttrss_user_entries where owner_uid = ".$_SESSION["uid"]." and uuid != ''");
 
@@ -34,6 +40,9 @@ class VF_Shared extends Plugin {
 
 	//function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false) {
 
+	/**
+	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+	 */
 	function get_headlines($feed_id, $options) {
 		/*$qfh_ret = queryFeedHeadlines(-4,
 			$options['limit'],
@@ -71,5 +80,4 @@ class VF_Shared extends Plugin {
 		return $qfh_ret;
 	}
 
-}
-?>
+}

+ 5 - 0
utils/gitlab-ci/phpmd-ruleset.xml

@@ -9,6 +9,11 @@
 
 	<!-- phpmd author is a bit weird i guess -->
 
+	<rule ref="rulesets/cleancode.xml">
+		<exclude name="BooleanArgumentFlag" />
+		<exclude name="ElseExpression" />
+	</rule>
+
 	<rule ref="rulesets/unusedcode.xml" />
 
 </ruleset>