-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor #405
Refactor #405
Conversation
include/lcp-category.php
Outdated
// OR relationship, default | ||
if ('yes' === $mode || '' === $mode) return implode(',', $cats); | ||
// Exclude current categories | ||
if ('other' === $mode) return implode(',', array_map(function($cat) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
4ceaace
to
1ac2e91
Compare
1530e30
to
2859496
Compare
/* | ||
* Create date_query args according to https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters | ||
*/ | ||
public function create_date_query_args($args, $params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function create_date_query_args
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
/* | ||
* Create date_query args according to https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters | ||
*/ | ||
public function create_date_query_args($args, $params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function create_date_query_args
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
I've realised I have a few more branches with interesting improvements but some of them depend on #288 so will need to merge that first. |
07ee67e
to
48f1414
Compare
public function with_id($id){ | ||
if (preg_match('/\+/', $id)){ | ||
if ( preg_match('/(-[0-9]+)+/', $id, $matches) ){ | ||
public function with_id($cat_id){ | ||
if (preg_match('/\+/', $cat_id)){ | ||
if ( preg_match('/(-[0-9]+)+/', $cat_id, $matches) ){ | ||
$this->exclude = implode(',', explode("-", ltrim($matches[0], '-') )); | ||
} | ||
$lcp_category_id = array_map( 'intval', explode( "+", $id ) ); | ||
} else { | ||
$lcp_category_id = $id; | ||
return array_map( 'intval', explode( "+", $cat_id ) ); | ||
} | ||
return $lcp_category_id; | ||
return $cat_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole method is bugged, doing id="1+2-3"
doesn't work (nothing to do with your refactoring, it's been so for a long time). I'm preparing a PR to merge with this branch so that category things should be good and done.
@picandocodigo I've found something by accident while trying to help someone. The issue she's having does not exist on the master branch, but when I first accidentally tried it on the 'refactor' branch it did exist. Maybe something to do with date refactoring? |
@zymeth25 that's weird. Yeah I'm testing some stuff on this branch now, and |
|
Yeah I know she made a mistake with |
Code Climate has analyzed commit 5e286af and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
@zymeth25 I think this was the issue 5e286af, at least working for me locally now. |
@picandocodigo Yeah, works for me too. |
Thinking we should merge this PR and your 2 PRs and publish a new version on Monday 🤔 |
Yeah good idea. That's enough for a release, we should make sure all of it works in all the crazy user scenarios we don't know about 😄 |
Work in progress to do some refactorings, improve Code Climate grading, fix a few things and get this back on track.