<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3ACodeSniffer</id>
	<title>Development:CodeSniffer - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3ACodeSniffer"/>
	<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:CodeSniffer&amp;action=history"/>
	<updated>2026-05-06T20:46:59Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:CodeSniffer&amp;diff=10908&amp;oldid=prev</id>
		<title>Олег Давидович: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:CodeSniffer&amp;diff=10908&amp;oldid=prev"/>
		<updated>2024-10-21T08:51:04Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 08:51, 21 октября 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Олег Давидович</name></author>
	</entry>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:CodeSniffer&amp;diff=10907&amp;oldid=prev</id>
		<title>1&gt;TimHunt в 18:02, 29 апреля 2011</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:CodeSniffer&amp;diff=10907&amp;oldid=prev"/>
		<updated>2011-04-29T18:02:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
&lt;br /&gt;
==Note that code-sniffer is currently out of date with the the Moodle coding guidelines==&lt;br /&gt;
&lt;br /&gt;
Also, at the moment the code is horribly mixed up with /lib/pear/PHP/CodeSniffer. Someone should:&lt;br /&gt;
&lt;br /&gt;
A better alternative is: https://github.com/timhunt/moodle-local_codechecker&lt;br /&gt;
&lt;br /&gt;
This is an entirely self-contained plug-in with a nice web-interface. It does not check all of the coding style, but it covers a lot of the most important points. The things it does check are all in the coding rules. There should not be any false positives.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
===Scope===&lt;br /&gt;
This document describes the CodeSniffer tool added in Moodle 2.0, its purpose and usage.&lt;br /&gt;
&lt;br /&gt;
===Function===&lt;br /&gt;
The function of the CodeSniffer tool is to analyse PHP5 (only) code, apply a set of rules that match the [[Development:Coding_style | Moodle Coding Style]], and output a report showing which parts of the code do not conform to this style.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
===Simple example===&lt;br /&gt;
The script is located in lib/pear/PHP and is called runsniffer. To check the syntax of a given file (e.g. index.php), run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
lib/pear/PHP/runsniffer index.php&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get a report that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  FOUND 139 ERROR(S) AND 24 WARNING(S) AFFECTING 130 LINE(S)&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
     1 | WARNING | $Id$ tag is no longer required, please remove.&lt;br /&gt;
    28 | ERROR   | line indented incorrectly; expected 0 spaces, found 4&lt;br /&gt;
    50 | ERROR   | line indented incorrectly; expected 0 spaces, found 4&lt;br /&gt;
    50 | ERROR   | A cast statement must be followed by a single space&lt;br /&gt;
    55 | ERROR   | line indented incorrectly; expected 0 spaces, found 4&lt;br /&gt;
  ....&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first column shows the line at which the ERROR or WARNING was found. The CodeSniffer uses a set of rules which are still being defined, so that what is currently defined as ERROR or WARNING is likely to change in the near future. &lt;br /&gt;
&lt;br /&gt;
You should fix all ERRORs, but may safely ignore the WARNINGs. Fixing warnings will help your code be even more readable and consistent with other code that follow this standard.&lt;br /&gt;
&lt;br /&gt;
===Advanced Usage===&lt;br /&gt;
====Ignoring warnings====&lt;br /&gt;
You can run the CodeSniffer with the -n flag to ignore warnings:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
lib/pear/PHP/runsniffer -n index.php&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resulting output:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  FOUND 139 ERROR(S) AFFECTING 125 LINE(S)&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
    28 | ERROR | line indented incorrectly; expected 0 spaces, found 4&lt;br /&gt;
    50 | ERROR | line indented incorrectly; expected 0 spaces, found 4&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Recursive analysis====&lt;br /&gt;
If you give the name of a folder instead of a file, it will search, analyse and report on all PHP files found in this folder and all its subfolders. This will produce a full report for each PHP file. Since this is likely to be too much information, you may want to print only a summary report, by using the following syntax (search the files/ folder as an example):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
lib/pear/PHP/runsniffer --report=summary files&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Report:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  PHP CODE SNIFFER REPORT SUMMARY&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  FILE                                                            ERRORS  WARNINGS&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  /web/htdocs/moodle_blog2/files/index.php                        11      58&lt;br /&gt;
  /web/htdocs/moodle_blog2/files/draftfiles.php                   6       22&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  A TOTAL OF 17 ERROR(S) AND 80 WARNING(S) WERE FOUND IN 2 FILE(S)&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also use the -n flag to ignore warnings.&lt;br /&gt;
&lt;br /&gt;
====Several files in one folder====&lt;br /&gt;
If you want to search all files under a folder, but not recurse through the subfolders, you can use the -l flag (local files only):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
lib/pear/PHP/runsniffer --report=summary -l grade&lt;br /&gt;
&lt;br /&gt;
  PHP CODE SNIFFER REPORT SUMMARY&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  FILE                                                            ERRORS  WARNINGS&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  /web/htdocs/moodle_blog2/grade/index.php                        0       2&lt;br /&gt;
  /web/htdocs/moodle_blog2/grade/lib.php                          6       210&lt;br /&gt;
  /web/htdocs/moodle_blog2/grade/querylib.php                     5       39&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
  A TOTAL OF 11 ERROR(S) AND 251 WARNING(S) WERE FOUND IN 3 FILE(S)&lt;br /&gt;
  --------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can pass as many files and folders to the script as you want, the analysis and flags will apply to all of them.&lt;br /&gt;
&lt;br /&gt;
===Special rules===&lt;br /&gt;
When recursing through folders, the CodeSniffer script looks for a file called thirdpartylibs.xml. Currently there is only one, found under lib/. It lists directories and files which are meant to stay &amp;#039;as-is&amp;#039; in Moodle, in order to ensure minimum hassle when upgrading these libraries. You can use this file as a template to create your own list of exceptions.&lt;br /&gt;
&lt;br /&gt;
===Other report formats===&lt;br /&gt;
CodeSniffer can export its reports in the following formats:&lt;br /&gt;
#full: default, shown first above&lt;br /&gt;
#summary: also shown above&lt;br /&gt;
#xml: Simple XML format&lt;br /&gt;
#csv: Comma-separated list&lt;br /&gt;
#checkstyle: XML format intended for use with CruiseControl&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
#[[Development:Coding]]&lt;br /&gt;
#[[Development:Coding style]]&lt;/div&gt;</summary>
		<author><name>1&gt;TimHunt</name></author>
	</entry>
</feed>