Ver Fonte

Add spell checking with typos (#4138)

* Add spell checking with typos
Implement https://github.com/FreshRSS/FreshRSS/pull/4134#issuecomment-1008027558

* GitHub Actions attempt

* Quiet wget

* Makefile
Alexandre Alapetite há 4 anos atrás
pai
commit
4e2dff4591

+ 14 - 1
.github/workflows/tests.yml

@@ -79,7 +79,7 @@ jobs:
       uses: actions/cache@v2
       with:
         path: bin
-        key: ${{ runner.os }}-bin-shfmt@v3.4.0c-hadolint@v2.7.0
+        key: ${{ runner.os }}-bin-shfmt@v3.4.0c-hadolint@v2.7.0-typos@v1.3.3
 
     - name: Add ./bin/ to $PATH
       run: mkdir -p bin/ && echo "${PWD}/bin" >> $GITHUB_PATH
@@ -106,3 +106,16 @@ jobs:
 
     - name: Check Dockerfile syntax
       run: find . -name 'Dockerfile*' -print0 | xargs -0 -n1 ./bin/hadolint --failure-threshold warning
+
+    - name: Install typos
+      if: steps.shell-cache.outputs.cache-hit != 'true'
+      run: |
+        cd bin ;
+        wget -q 'https://github.com/crate-ci/typos/releases/download/v1.3.3/typos-v1.3.3-x86_64-unknown-linux-musl.tar.gz' &&
+        tar -xvf *.tar.gz './typos' &&
+        chmod +x typos &&
+        rm *.tar.gz ;
+        cd ..
+
+    - name: Check spelling
+      run: bin/typos

+ 39 - 0
.typos.toml

@@ -0,0 +1,39 @@
+[default.extend-identifiers]
+ba9 = "ba9"
+Ths2 = "Ths2"
+
+[files]
+extend-exclude = [
+	"*.fr.md",
+	"*.map",
+	"*.min.js",
+	"*.po",
+	"*.pot",
+	"*.rtl.css",
+	"app/i18n/cz/",
+	"app/i18n/de/",
+	"app/i18n/es/",
+	"app/i18n/fr/",
+	"app/i18n/he/",
+	"app/i18n/it/",
+	"app/i18n/ja/",
+	"app/i18n/ko/",
+	"app/i18n/nl/",
+	"app/i18n/oc/",
+	"app/i18n/pl/",
+	"app/i18n/pt-br/",
+	"app/i18n/ru/",
+	"app/i18n/sk/",
+	"app/i18n/tr/",
+	"app/i18n/zh-cn/",
+	"bin/",
+	"data/",
+	"docs/fr/",
+	"lib/lib_phpQuery.php",
+	"lib/PHPMailer",
+	"lib/SimplePie/",
+	"node_modules/",
+	"p/scripts/vendor/",
+	"package-lock.json",
+	"vendor/",
+]

+ 14 - 1
Makefile

@@ -82,6 +82,15 @@ bin/phpcbf:
 	wget -O bin/phpcbf https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.5/phpcbf.phar
 	echo '6f64fe00dee53fa7b256f63656dc0154f5964666fc7e535fac86d0078e7dea41 bin/phpcbf' | sha256sum -c - || rm bin/phpcbf
 
+bin/typos:
+	mkdir -p bin/
+	cd bin ; \
+	wget -q 'https://github.com/crate-ci/typos/releases/download/v1.3.3/typos-v1.3.3-x86_64-unknown-linux-musl.tar.gz' && \
+	tar -xvf *.tar.gz './typos' && \
+	chmod +x typos && \
+	rm *.tar.gz ; \
+	cd ..
+
 ##########
 ## I18N ##
 ##########
@@ -192,9 +201,13 @@ npm-test:
 npm-fix:
 	npm run fix
 
+.PHONY: typos-test
+typos-test: bin/typos
+	bin/typos
+
 # TODO: Add shellcheck, shfmt, hadolint
 .PHONY: test-all
-test-all: composer-test npm-test
+test-all: composer-test npm-test typos-test
 
 .PHONY: fix-all
 fix-all: composer-fix npm-fix

+ 8 - 8
app/Controllers/statsController.php

@@ -23,25 +23,25 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
 		FreshRSS_View::prependTitle(_t('admin.stats.title') . ' · ');
 	}
 
-	private function convertToSerie($data) {
-		$serie = array();
+	private function convertToSeries($data) {
+		$series = array();
 
 		foreach ($data as $key => $value) {
-			$serie[] = array($key, $value);
+			$series[] = array($key, $value);
 		}
 
-		return $serie;
+		return $series;
 	}
 
-	private function convertToPieSerie($data) {
-		$serie = array();
+	private function convertToPieSeries($data) {
+		$series = array();
 
 		foreach ($data as $value) {
 			$value['data'] = array(array(0, (int) $value['data']));
-			$serie[] = $value;
+			$series[] = $value;
 		}
 
-		return $serie;
+		return $series;
 	}
 
 	/**

+ 1 - 1
app/Models/Share.php

@@ -121,7 +121,7 @@ class FreshRSS_Share {
 
 	/**
 	 * Update a FreshRSS_Share object with information from an array.
-	 * @param array<string,string> $options is a list of informations to update where keys should be
+	 * @param array<string,string> $options is a list of information to update where keys should be
 	 *        in this list: name, url, id, title, link.
 	 */
 	public function update($options) {

+ 1 - 4
lib/Minz/ActionController.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe ActionController représente le contrôleur de l'application
+ * The Minz_ActionController class is a controller in the MVC paradigm
  */
 class Minz_ActionController {
 	protected $view;
@@ -16,9 +16,6 @@ class Minz_ActionController {
 	// Gives the possibility to override the default View type.
 	public static $viewType = 'Minz_View';
 
-	/**
-	 * Constructeur
-	 */
 	public function __construct () {
 		if (class_exists(self::$viewType)) {
 			$this->view = new self::$viewType();

+ 4 - 5
lib/Minz/Error.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe Error permet de lancer des erreurs HTTP
+ * The Minz_Error class logs and raises framework errors
  */
 class Minz_Error {
 	public function __construct () { }
@@ -48,10 +48,9 @@ class Minz_Error {
 	}
 
 	/**
-	 * Permet de retourner les logs de façon à n'avoir que
-	 * ceux que l'on veut réellement
-	 * @param array<string,string>|string $logs les logs rangés par catégories (error, warning, notice)
-	 * @return array<string> liste des logs, sans catégorie, en fonction de l'environment
+	 * Returns filtered logs
+	 * @param array<string,string>|string $logs logs sorted by category (error, warning, notice)
+	 * @return array<string> list of matching logs, without the category, according to environment preferences (production / development)
 	 */
 	private static function processLogs ($logs) {
 		$conf = Minz_Configuration::get('system');

+ 5 - 4
lib/Minz/FrontController.php

@@ -19,8 +19,9 @@
 # ***** END LICENSE BLOCK *****
 
 /**
- * La classe FrontController est le Dispatcher du framework, elle lance l'application
- * Elle est appelée en général dans le fichier index.php à la racine du serveur
+ * The Minz_FrontController class is the framework Dispatcher.
+ * It runs the application.
+ * It is generally invoqued by an index.php file at the root.
  */
 class Minz_FrontController {
 	protected $dispatcher;
@@ -50,8 +51,8 @@ class Minz_FrontController {
 	}
 
 	/**
-	 * Retourne un tableau représentant l'url passée par la barre d'adresses
-	 * @return array représentant l'url
+	 * Returns an array representing the URL as passed in the address bar
+	 * @return array URL representation
 	 */
 	private function buildUrl() {
 		$url = array();

+ 1 - 1
lib/Minz/Helper.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe Helper représente une aide pour des tâches récurrentes
+ * The Minz_Helper class contains some misc. help functions
  */
 class Minz_Helper {
 

+ 1 - 15
lib/Minz/Log.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe Log permet de logger des erreurs
+ * The Minz_Log class is used to log errors and warnings
  */
 class Minz_Log {
 	/**
@@ -107,20 +107,6 @@ class Minz_Log {
 		}
 	}
 
-	/**
-	 * Automatise le log des variables globales $_GET et $_POST
-	 * Fait appel à la fonction record(...)
-	 * Ne fonctionne qu'en environnement "development"
-	 * @param string $file_name fichier de log
-	 */
-	public static function recordRequest($file_name = null) {
-		$msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true));
-		$msg_post = str_replace("\n", '', '$_POST content : ' . print_r($_POST, true));
-
-		self::record($msg_get, LOG_DEBUG, $file_name);
-		self::record($msg_post, LOG_DEBUG, $file_name);
-	}
-
 	/**
 	 * Some helpers to Minz_Log::record() method
 	 * Parameters are the same of those of the record() method.

+ 1 - 1
lib/Minz/Model.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe Model représente un modèle de l'application (représentation MVC)
+ * The Minz_Model class represents a model in the MVC paradigm.
  */
 class Minz_Model {
 

+ 1 - 1
lib/Minz/ModelArray.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe Model_array représente le modèle interragissant avec les fichiers de type texte gérant des tableaux php
+ * The Minz_ModelArray class is the model to interact with text files containing a PHP array
  */
 class Minz_ModelArray {
 	/**

+ 1 - 1
lib/Minz/Paginator.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe Paginator permet de gérer la pagination de l'application facilement
+ * The Minz_Paginator is used to handle paging
  */
 class Minz_Paginator {
 	/**

+ 1 - 1
lib/Minz/Session.php

@@ -1,7 +1,7 @@
 <?php
 
 /**
- * La classe Session gère la session utilisateur
+ * The Minz_Session class handles user’s session
  */
 class Minz_Session {
 	private static $volatile = false;

+ 10 - 10
lib/Minz/Url.php

@@ -1,21 +1,21 @@
 <?php
 
 /**
- * La classe Url permet de gérer les URL à travers MINZ
+ * The Minz_Url class handles URLs across the MINZ framework
  */
 class Minz_Url {
 	/**
-	 * Affiche une Url formatée
-	 * @param string|array<string,string|array<string,mixed>> $url l'url à formater définie comme un tableau :
+	 * Display a formatted URL
+	 * @param string|array<string,string|array<string,mixed>> $url The URL to format, defined as an array:
 	 *                    $url['c'] = controller
 	 *                    $url['a'] = action
-	 *                    $url['params'] = tableau des paramètres supplémentaires
-	 *             ou comme une chaîne de caractère
-	 * @param string $encodage pour indiquer comment encoder les & (& ou &amp; pour html)
+	 *                    $url['params'] = array of additional parameters
+	 *             or as a string
+	 * @param string $encoding how to encode & (& ou &amp; pour html)
 	 * @param bool|string $absolute
-	 * @return string url formatée
+	 * @return string Formatted URL
 	 */
-	public static function display ($url = array (), $encodage = 'html', $absolute = false) {
+	public static function display ($url = array (), $encoding = 'html', $absolute = false) {
 		$isArray = is_array($url);
 
 		if ($isArray) {
@@ -44,8 +44,8 @@ class Minz_Url {
 		}
 
 		if ($isArray) {
-			$url_string .= '/' . self::printUri($url, $encodage);
-		} elseif ($encodage === 'html') {
+			$url_string .= '/' . self::printUri($url, $encoding);
+		} elseif ($encoding === 'html') {
 			$url_string = Minz_Helper::htmlspecialchars_utf8($url_string . $url);
 		} else {
 			$url_string .= $url;

+ 1 - 1
lib/Minz/View.php

@@ -5,7 +5,7 @@
 */
 
 /**
- * La classe View représente la vue de l'application
+ * The Minz_View represents a view in the MVC paradigm
  */
 class Minz_View {
 	const VIEWS_PATH_NAME = '/views';

+ 7 - 7
lib/lib_opml.php

@@ -131,17 +131,17 @@ function preprocessing_categories($doc) {
 	foreach ($outlines as $outline) {
 		$category = trim($outline->getAttribute('category'));
 		if ($category != '') {
-			$outline_categorie = null;
+			$outline_category = null;
 			if (!isset($outline_categories[$category])) {
-				$outline_categorie = $doc->createElement('outline');
-				$outline_categorie->setAttribute('text', $category);
-				$body->insertBefore($outline_categorie, $body->firstChild);
-				$outline_categories[$category] = $outline_categorie;
+				$outline_category = $doc->createElement('outline');
+				$outline_category->setAttribute('text', $category);
+				$body->insertBefore($outline_category, $body->firstChild);
+				$outline_categories[$category] = $outline_category;
 			} else {
-				$outline_categorie = $outline_categories[$category];
+				$outline_category = $outline_categories[$category];
 			}
 			$outline->parentNode->removeChild($outline);
-			$outline_categorie->appendChild($outline);
+			$outline_category->appendChild($outline);
 		}
 	}
 }

+ 1 - 1
lib/lib_rss.php

@@ -160,7 +160,7 @@ function escapeToUnicodeAlternative($text, $extended = true) {
 
 function format_number($n, $precision = 0) {
 	// number_format does not seem to be Unicode-compatible
-	return str_replace(' ', ' ',	//Espace fine insécable
+	return str_replace(' ', ' ',	// Thin non-breaking space
 		number_format($n, $precision, '.', ' ')
 	);
 }

+ 3 - 3
p/scripts/global_view.js

@@ -34,9 +34,9 @@ function load_panel(link) {
 		document.getElementById('overlay').classList.add('visible');
 		panel.classList.add('visible');
 
-		// force le démarrage du scroll en haut.
-		// Sans ça, si l’on scroll en lisant une catégorie par exemple,
-		// en en ouvrant une autre ensuite, on se retrouve au même point de scroll
+		// Force the initial scroll to the top.
+		// Without it, if one scrolls down in a category (for instance)
+		// and then open another one, we risk being at the same scroll position
 		panel.scrollTop = 0;
 		document.documentElement.scrollTop = 0;
 

+ 1 - 1
p/themes/Ansum/_components.scss

@@ -101,7 +101,7 @@
 }
 
 .tree .tree-folder .tree-folder-items .dropdown-menu {
-	// tout ça sert à restaurer l’apparence du dropdown dans un contexte de sidebar sombre
+	// to reset the appearance of the dropdown in the case of a dark sidebar
 	.item {
 		padding: 0;
 

+ 1 - 1
p/themes/Ansum/_variables.scss

@@ -45,7 +45,7 @@ $fav-light: #fff6da;
 // la couleur de sidebar, utile si on a envie d’un thème qui aurait une sidebar foncé, e.g.
 $sid-font-color: #363330; // la couleur de fond de la barre de gauche et du header
 $sid-bg: #fbf9f6; // le background général de la barre de gauche, et du header
-$sid-bg-alt: #f7f2ea; // le background de l’intérieur des groupes
+$sid-bg-alt: #f7f2ea; // background inside groups
 $sid-bg-dark: #efe3d3; // les hovers
 $sid-sep: #f0e7da; // les séparateurs
 $sid-active: $main-first; // la couleur active

+ 1 - 1
p/themes/Dark/metadata.json

@@ -1,7 +1,7 @@
 {
 	"name": "Dark",
 	"author": "AD",
-	"description": "Le coté obscur du thème “Origine”",
+	"description": "The dark side of the “Origine” theme",
 	"version": 0.2,
 	"files": ["_template.css", "dark.css"]
 }

+ 1 - 1
p/themes/Mapco/_components.scss

@@ -100,7 +100,7 @@
 }
 
 .tree .tree-folder .tree-folder-items .dropdown-menu {
-	// tout ça sert à restaurer l’apparence du dropdown dans un contexte de sidebar sombre
+	// to reset the appearance of the dropdown in the case of a dark sidebar
 	.item {
 		padding: 0;
 

+ 1 - 1
p/themes/Mapco/_variables.scss

@@ -45,7 +45,7 @@ $fav-light: #fff6da;
 // la couleur de sidebar, utile si on a envie d’un thème qui aurait une sidebar foncé, e.g.
 $sid-font-color: #fff; // la couleur de fond de la barre de gauche et du header
 $sid-bg: #303136; // le background général de la barre de gauche, et du header
-$sid-bg-alt: #26272a; // le background de l’intérieur des groupes
+$sid-bg-alt: #26272a; // background inside groups
 $sid-bg-dark: #17181a; // les hovers
 $sid-sep: #3f3f3f; // les séparateurs
 $sid-active: $main-first; // la couleur active