Function prepareEntityTranslations
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function prepareEntityTranslations($entity_type, $entity) {
if (entity_translation_enabled($entity_type)) {
if ($handler = entity_translation_get_handler($entity_type, $entity)) {
// Fetch all the languages that have field data for this entity.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function prepare
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function prepare($object, $row) {
// Note there is no parent::prepare($object, $row) here since there is no
// parent to call.
// Apply entity-generic alterations before the entity object is saved.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getEntityFieldLangcodes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getEntityFieldLangcodes($entity_type, $entity) {
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
$instances = field_info_instances($entity_type, $bundle);
$langcodes = array();
foreach (array_keys($instances) as $field) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Inline comments must end in full-stops, exclamation marks, colons, question marks, or closing parentheses Open
// in each
- Exclude checks
If the line declaring an array spans longer than 80 characters, each element should be broken into its own line Open
foreach (array('language', 'created', 'status', 'promote', 'sticky', 'uid') as $key) {
- Exclude checks
Missing function doc comment Open
public function getEntityFieldLangcodes($entity_type, $entity) {
- Exclude checks
Inline comments must end in full-stops, exclamation marks, colons, question marks, or closing parentheses Open
// Before saving any translations, ensure
- Exclude checks
Missing function doc comment Open
public function prepare($object, $row) {
- Exclude checks
Missing @var tag in member variable comment Open
*/
- Exclude checks
The closing brace for the class must have an empty line before it Open
}
- Exclude checks
Missing function doc comment Open
public function __construct($group = NULL) {
- Exclude checks
Missing function doc comment Open
public function prepareEntityTranslations($entity_type, $entity) {
- Exclude checks
No space found before comment text; expected "// $handler->initTranslations();" but found "//$handler->initTranslations();" Open
//$handler->initTranslations();
- Exclude checks
Comments may not appear after statements Open
'status' => 1, // Set translations to published by default.
- Exclude checks
Missing function doc comment Open
public function preserveValues($node) {
- Exclude checks
Expected 1 blank line after function; 0 found Open
}
- Exclude checks
Inline comments must end in full-stops, exclamation marks, colons, question marks, or closing parentheses Open
// Always call the parent constructor first for basic setup
- Exclude checks