Showing 1,011 of 9,214 total issues
Function getPhotos
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getPhotos($items_per_page = 25, $page_num = 1, $date_from = false, $date_to = false) {
if (!empty($this->flickr_oauth_secret) && !empty($this->flickr_oauth_token)) {
// Fetch photos using OAuth
$f = new flickr_railpage(RP_FLICKR_API_KEY);
$f->oauth_token = $this->flickr_oauth_token;
- 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 validate
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function validate() {
if (is_null($this->bbcode_uid)) {
$this->bbcode_uid = "sausages";
}
- 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 photos
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function photos($items_per_page, $page, $extras, $sort = true) {
$url = "https://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=" . RP_FLICKR_API_KEY . "&user_id=" . $this->nsid . "&extras=" . $extras . "&per_page=" . $items_per_page . "&page=" . $page . "&format=json&nojsoncallback=1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
- 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 fetch
has 43 lines of code (exceeds 25 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");
}
Method StopsNearLocation
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function StopsNearLocation($latitude = null, $longitude = null) {
if ($latitude == null) {
throw new Exception("Cannot fetch " . __METHOD__ . " - no latitude given");
}
Method getImageExif
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getImageExif(Image $imageObject, $force = false) {
Debug::LogCLI("Fetching EIXF data for image ID " . $imageObject->id);
if (!$force && isset($imageObject->meta['exif']) && $imageObject->meta['exif_format_version'] >= self::EXIF_FORMAT_VERSION) {
Method notifyWinner
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function notifyWinner(Competition $compObject) {
if (isset($compObject->meta['winnernotified']) && $compObject->meta['winnernotified'] === true) {
return $this;
}
Method getIcon
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getIcon() {
$mime = explode("/", $this->mime);
switch ($mime[0]) {
Method commit
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function commit() {
if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
throw new Exception("Cannot commit changes to PM - PM does not exist!");
}
Method send
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function send() {
$this->validate();
$from_email = $this->data['author']['username'] == "Railpage System User" ? $this->Config->SMTP->username : $this->data['author']['email'];
Method activeThreads
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function activeThreads($num_threads = 1, $age) {
if (empty($age)) {
$age = strtotime("30 days ago");
}
Method validate
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate($ignore = false) {
if (empty( $this->username )) {
throw new Exception("Username cannot be empty");
}
Method getArray
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getArray() {
//$now = new DateTime;
$voting_open = Utility\CompetitionUtility::isVotingWindowOpen($this);
$submissions_open = Utility\CompetitionUtility::isSubmissionWindowOpen($this);
Method commit
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function commit() {
$this->validate();
$user_id = isset( $this->author->User ) && $this->author->User instanceof User ? $this->author->User->id : 0;
Method deleteObjects
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deleteObjects($object_id = false) {
if (!$object_id) {
//throw new Exception("Cannot delete objects - no object ID given");
return false;
}
Method Process
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function Process( $text ) {
$timer = Debug::GetTimer();
$r = '';
Method getEmoticons
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getEmoticons() {
return [
'icon_mad' => [ ':angry:', '>(', '>:(', '>[', '>:[' ],
'icon_cool' => [ ':sunglasses:', ':cool:', '8)', '8]', '[:cool:]', '8-)' ],
Method getArray
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getArray() {
$array = array(
"id" => $this->id,
"date" => array(
"absolute" => $this->Date->format("Y-m-d H:i:s"),
Method commit
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function commit() {
$this->validate();
$data = array(
Method cleanupBadHtml
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function cleanupBadHtml($string, $editorVersion = 1) {
$timer = Debug::getTimer();
if (is_string($string)) {