Showing 137 of 273 total issues
Function reducer
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const reducer = (state: State, action: Action): State => {
switch (action.type) {
case getType(actions.startup.request):
return {
...state,
Method repos
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function repos( WP_REST_Request $request ) {
$args = [ 'with' => [ 'blobs' => [] ] ];
$search_term = $request->get_param( 's' );
Method process_item
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function process_item( $repo ) {
if ( ! ( $repo instanceof Repo ) ) {
$this->log(
sprintf(
/* translators: %s: Invalid type for repo. */
Method refresh
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function refresh( array $attributes ) {
try {
$prev_blobs = $this->blobs;
} catch ( \Exception $exception ) {
$prev_blobs = new Collection( Blob::class );
Method process_item
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function process_item( $gist ) {
if ( ! ( $gist instanceof stdClass ) ) {
$this->log(
sprintf(
/* translators: %s: Item type. */
Function reducer
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const reducer: EddyReducer<State, RootAction> = (
state: State,
action: RootAction,
) => {
switch (state.status) {
Function update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function update( WP_REST_Request $request ) {
$repo_id = $request->get_param( 'repo_id' );
$repo = $this->em->find( Repo::class, $repo_id );
- 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 get
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function get( $args, $assoc_args ) {
if ( ! isset( $args[0] ) ) {
$value = $this->options->all();
} else {
$key = $args[0];
- 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 merge
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function merge( array $attributes ) {
try {
$blobs = $this->blobs;
} catch ( \Exception $exception ) {
$blobs = new Collection( Blob::class );
Method process_entrypoint
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function process_entrypoint( Register $assets, $entry, $files, $deps ) {
if ( ! isset( $this->asset_config[ $entry ] ) ) {
throw new Exception( 'Unexpected entry in manifest: ' . $entry );
}
Method apply
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function apply( WP_REST_Request $request ) {
$id = $request->get_param( 'id' );
$model = $this->em->find( Repo::class, $id, array(
'with' => array(
'blobs' => array(
Method delete
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete( Model $model, $force = false ) {
global $wpdb;
$results = $wpdb->delete(
$this->em->make_table_name( $model ),
Method update
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update( WP_REST_Request $request ) {
$id = $request->get_param( 'id' );
$model = $this->em->find( Repo::class, $id, array(
'with' => array(
Method create_gist_for_repo
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function create_gist_for_repo( Repo $repo ) {
$response = $this->client->create( $this->map_repo_to_new_entity( $repo ) );
if ( is_wp_error( $response ) ) {
$this->log_response_error( $repo, $response );
Method filter_hooks
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filter_hooks() {
return array(
array(
'hook' => 'the_content',
'method' => 'post_content',
Method do_shortcode
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function do_shortcode( array $attrs, $content = '' ) {
$args = shortcode_atts( static::$defaults, $attrs, 'gistpen' );
// If the user didn't provide an ID, raise an error
if ( ! $args['id'] ) {
Method create
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
public function create( $args, $assoc_args ) {
if ( ! empty( $args[0] ) ) {
$assoc_args['code'] = $this->read_from_file_or_stdin( $args[0] );
}
Function patch
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function patch( $user_id, array $update ) {
$options = $this->all( $user_id );
foreach ( $update as $key => $value ) {
if ( ! isset( $options[ $key ] ) ) {
- 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 setSelectionRange
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const setSelectionRange = (node: Element, ss: number, se: number) =>
Kefir.stream<never, never>(emitter => {
if (ss === selectSelectionStart(node) && se === selectSelectionEnd(node)) {
return emitter.end();
}
- 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 entity_matches_gist
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function entity_matches_gist( $entity, $gist ) {
if ( $entity['description'] !== $gist->description ) {
return false;
}