Download the PHP package bmitch/codor without Composer
On this page you can find all versions of the php package bmitch/codor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package codor
Code Odor Sniffer
:nose: :poop: Custom PHP Code Sniffer sniffs to help find Code Smells (Odor).
Inspired by: https://github.com/object-calisthenics/phpcs-calisthenics-rules
- What Is it?
- Compatibility
- How to Install?
- How to Use?
- Omitting Sniffs
- Running Specific Sniffs
- Sniffs Included
- Customizing Sniffs
- Customizations Available
- Similar Packages
- Contributing
- License
What is it?
This package is a set of custom Sniffs for the PHP Code Sniffer that you can use in your CI build to ensure the ingegrity of your code base.
Compatibility
- PHP 7.1+ please use v1.0.0 and above.
- PHP 5.6 and below please use any version below v1.0.0.
How to Install?
Install via Composer:
How to Use?
Create a PHPCS ruleset XML (codor.xml
or whatever filename you want) file in the root of your project.
Then run it with the command:
Where src
is the location of the source code you want to check.
Omitting Sniffs
You may not want to run all the sniffs provided so you can specify which sniffs you want to exclude with the --exclude
flag like:
(if you want to exclude multiple just separate them with a comma)
Running Specific Sniffs
Or you can also specify which sniffs to specifically run:
Suppressing the sniffs on specific pieces of code
Please see the PHPCS documentation:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders
Sniffs Included
Codor.ControlStructures.NoElse
Does not allow for any else
or elseif
statements.
:x:
:white_check_mark:
Codor.Files.FunctionLength
Functions/methods must be no more than 20 lines.
:x:
:white_check_mark:
Codor.Files.FunctionParameter
Functions/methods must have no more than 3 parameters.
:x:
:white_check_mark:
Codor.Files.ReturnNull
Functions/methods must not return null
.
:x:
:white_check_mark:
Codor.Files.MethodFlagParameter
Functions/methods cannot have parameters that default to a boolean.
:x:
:white_check_mark:
Codor.Classes.ClassLength
Classes must be no more than 200 lines.
:x:
:white_check_mark:
Codor.Classes.ConstructorLoop
Class constructors must not contain any loops.
:x:
:white_check_mark:
Codor.Classes.Extends
Warns if a class extends another class. Goal is to promote composition over inheritance (https://en.wikipedia.org/wiki/Composition_over_inheritance).
:x:
:white_check_mark:
Codor.Classes.FinalPrivate
Final classes should not contain protected methods or variables. Should use private instead.
:x:
:white_check_mark:
Codor.Classes.NewInstance
Classes should not instantiate objects. Should use dependency injection.
:x:
:white_check_mark:
Codor.Classes.PropertyDeclaration
Produces an error if your class uses undeclared member variables. Only warns if class extends another class.
:x:
:white_check_mark:
Codor.Files.FunctionNameContainsAndOr
Functions/methods cannot contain "And" or "Or". This could be a sign of a function that does more than one thing.
:x:
:white_check_mark:
Codor.Files.IndentationLevel
Functions/methods cannot have more than 2 level of indentation.
:x:
:white_check_mark:
Codor.ControlStructures.NestedIf
Nested if statements are not allowed.
:x:
:white_check_mark:
Codor.Syntax.NullCoalescing
Produces an error if a line contains a ternary operator that could be converted to a Null Coalescing operator.
:x:
:white_check_mark:
Codor.Syntax.LinesAfterMethod
Only allows for 1 line between functions/methods. Any more than 1 will produce an error.
:x:
:white_check_mark:
Codor.TypeHints.MixedReturnType
Prevents you from having a mixed
type returned in a doc block.
:x:
:white_check_mark:
Customizing Sniffs
Some of the sniff rules can be customized to your liking. For example, if you'd want the Codor.Files.FunctionLength
to make sure your functions are no more than 30 lines instead of 20, you can do that. Here's an example of a codor.xml
file with that customization:
Customizations Available
Codor.Files.FunctionLength
maxLength
: The maximum number of lines a function/method can have (default = 20).
Codor.Files.FunctionParameter
maxParameters
: The maximum number of parameters a function/method can have (default = 3).
Codor.Classes.ClassLength
maxLength
: The maximum number of lines a Class can have (default = 200).
Codor.Files.IndentationLevel
indentationLimit
: Cannot have more than or equal to this number of indentations (default = 2).
Similar Packages
- https://github.com/object-calisthenics/phpcs-calisthenics-rules
- https://github.com/slevomat/coding-standard
Contributing
Please see CONTRIBUTING.md
License
The MIT License (MIT). Please see License File for more information.