File livejournal.php
has 830 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* LiveJournal API Importer
*
LJ_API_Import
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class LJ_API_Import {
var $comments_url = 'http://www.livejournal.com/export_comments.bml';
var $ixr_url = 'http://www.livejournal.com/interface/xmlrpc';
var $ixr;
Function step1
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function step1() {
global $verified;
set_time_limit( 0 );
update_option( 'ljapi_step', 1 );
if ( !$this->ixr ) $this->ixr = new IXR_Client( $this->ixr_url, false, 80, 30 );
- 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 step1
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function step1() {
global $verified;
set_time_limit( 0 );
update_option( 'ljapi_step', 1 );
if ( !$this->ixr ) $this->ixr = new IXR_Client( $this->ixr_url, false, 80, 30 );
Method parse_comment
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parse_comment( $comment ) {
global $wpdb;
// Get the top-level attributes
preg_match( '|<comment([^>]+)>|i', $comment, $attribs );
Method greet
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function greet() {
?>
<div class="narrow">
<form action="admin.php?import=livejournal" method="post">
<?php wp_nonce_field( 'lj-api-import' ) ?>
Method import_post
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function import_post( $post ) {
global $wpdb;
// Make sure we haven't already imported this one
if ( $this->get_wp_post_ID( $post['itemid'] ) )
Method setup
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setup() {
global $verified;
// Get details from form or from DB
if ( !empty( $_POST['lj_username'] ) && !empty( $_POST['lj_password'] ) ) {
// Store details for later
Method step2
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function step2() {
set_time_limit( 0 );
update_option( 'ljapi_step', 2 );
$this->username = get_option( 'ljapi_username' );
$this->password = get_option( 'ljapi_password' );
Function download_comment_meta
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function download_comment_meta() {
$cookie = $this->get_session();
if ( is_wp_error( $cookie ) )
return $cookie;
- 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 step3
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function step3() {
global $wpdb;
set_time_limit( 0 );
update_option( 'ljapi_step', 3 );
Function setup
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function setup() {
global $verified;
// Get details from form or from DB
if ( !empty( $_POST['lj_username'] ) && !empty( $_POST['lj_password'] ) ) {
// Store details for later
- 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 download_post_bodies
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function download_post_bodies() {
$imported_count = (int) get_option( 'ljapi_imported_count' );
$sync_item_times = get_option( 'ljapi_sync_item_times' );
$lastsync = get_option( 'ljapi_lastsync_posts' );
if ( !$lastsync )
- 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 download_post_bodies
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function download_post_bodies() {
$imported_count = (int) get_option( 'ljapi_imported_count' );
$sync_item_times = get_option( 'ljapi_sync_item_times' );
$lastsync = get_option( 'ljapi_lastsync_posts' );
if ( !$lastsync )
Method download_comment_meta
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function download_comment_meta() {
$cookie = $this->get_session();
if ( is_wp_error( $cookie ) )
return $cookie;
Function import_post
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function import_post( $post ) {
global $wpdb;
// Make sure we haven't already imported this one
if ( $this->get_wp_post_ID( $post['itemid'] ) )
- 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 download_post_meta
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function download_post_meta() {
$total = (int) get_option( 'ljapi_total' );
$count = (int) get_option( 'ljapi_count' );
$lastsync = get_option( 'ljapi_lastsync' );
if ( !$lastsync ) {
Method download_comment_bodies
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function download_comment_bodies() {
global $wpdb;
$cookie = $this->get_session();
if ( is_wp_error( $cookie ) )
return $cookie;
Function download_comment_bodies
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function download_comment_bodies() {
global $wpdb;
$cookie = $this->get_session();
if ( is_wp_error( $cookie ) )
return $cookie;
- 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 download_post_meta
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function download_post_meta() {
$total = (int) get_option( 'ljapi_total' );
$count = (int) get_option( 'ljapi_count' );
$lastsync = get_option( 'ljapi_lastsync' );
if ( !$lastsync ) {
- 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 insert_postmeta
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function insert_postmeta( $post_id, $post ) {
// Need the original LJ id for comments
add_post_meta( $post_id, 'lj_itemid', $post['itemid'] );
// And save the permalink on LJ in case we want to link back or something
- 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
Avoid too many return
statements within this method. Open
return false;
Function parse_comment
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function parse_comment( $comment ) {
global $wpdb;
// Get the top-level attributes
preg_match( '|<comment([^>]+)>|i', $comment, $attribs );
- 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 step3
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function step3() {
global $wpdb;
set_time_limit( 0 );
update_option( 'ljapi_step', 3 );
- 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 lj_ixr
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function lj_ixr() {
if ( $challenge = $this->ixr->query( 'LJ.XMLRPC.getchallenge' ) ) {
$challenge = $this->ixr->getResponse();
}
if ( isset( $challenge['challenge'] ) ) {
- 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 step2
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function step2() {
set_time_limit( 0 );
update_option( 'ljapi_step', 2 );
$this->username = get_option( 'ljapi_username' );
$this->password = get_option( 'ljapi_password' );
- 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 dispatch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function dispatch() {
if ( empty( $_REQUEST['step'] ) )
$step = 0;
else
$step = (int) $_REQUEST['step'];
- 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"