Showing 708 of 9,214 total issues
Function validate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function validate() {
if ($this->class instanceof LocoClass && !$this->Class instanceof LocoClass) {
$this->Class = &$this->class;
}
- 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 fetch
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function fetch($method = null, $parameters = array(), $other = array()) {
if ($method == null && empty($parameters)) {
throw new Exception("Cannot fetch API query - no API method defined");
}
- 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 newPosts
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function newPosts($forums = false, $from_time = false, $items_per_page = 25, $start = 0) {
if (!$forums || !is_array($forums)) {
throw new \Exception("You must provide a list of forums this user has permission to view");
return false;
}
- 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
Method validate
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function validate() {
if (empty($this->title)) {
throw new Exception("Competition title cannot be empty");
}
Method cacheGeoData
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function cacheGeoData() {
if (!$this->Place instanceof Place) {
return $this;
}
Method send
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function send() {
$this->validate();
$data = array(
Method getRegions
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRegions($country = false) {
$timer = Debug::GetTimer();
$return = false;
Method bulkAddLocos
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function bulkAddLocos($firstLoco = null, $lastLoco = null, $gaugeId = null, $statusId = null, $manufacturerId = null, $prefix = "") {
if ($firstLoco == null) {
throw new Exception("Cannot add locomotives to class - first loco number was not provided");
}
Method __construct
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($user = false) {
if (!$user || !($user instanceof \Railpage\Users\User)) {
throw new \Exception("Cannot instantiate " . __CLASS__ . "::" . __FUNCTION__ . " - no \$user object given");
return false;
}
File LocomotiveUtility.php
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Locomotive utility class
* @since Version 3.9.1
Method generate
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate() {
$string = '';
global $handheld;
Method validate
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate() {
if (empty( $this->title )) {
throw new Exception("Validation failed: title is empty");
}
Method formatExif
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function formatExif($exif) {
$format = array();
// Aperture
Method getUpcoming
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getUpcoming($Date = false) {
if (!$Date) {
$Date = new DateTime;
$Date->add(new DateInterval("PT60M"));
}
Method load
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function load() {
if (empty($this->id) || $this->id === false) {
throw new Exception("Cannot load Railcam - empty or invalid ID given");
}
Method getJSON
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getJSON() {
if (isset( $this->author )) {
$author = clone $this->author;
Method resolveTemplate
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function resolveTemplate($template) {
if (pathinfo($template, PATHINFO_EXTENSION) == "tpl" && file_exists($template)) {
return $template;
}
Method __construct
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($id = NULL) {
parent::__construct();
$this->Module = new Module("events");
$this->namespace = $this->Module->namespace;
Method posts
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function posts($itemsPerPage = 25, $pageNum = 1, $sort = "ASC", $highlights = null) {
$highlight_sql = "";
if (!is_null($highlights)) {
Method hybi10Encode
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function hybi10Encode($payload, $type = 'text', $masked = true)
{
$frameHead = array();
$payloadLength = strlen($payload);
switch ($type) {