intraxia/wp-gistpen

View on GitHub

Showing 137 of 273 total issues

Method fill_relations has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function fill_relations( Model $model, array $params ) {
        if ( ! isset( $params['with'] ) ) {
            $params['with'] = array();
        }

Severity: Minor
Found in app/Database/Repository/AbstractRepository.php - About 1 hr to fix

    Method find has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function find( $class, $id, array $params = array() ) {
            $post_type = $class::get_post_type();
            $post      = get_post( $id );
    
            if ( ! $post || $post->post_type !== $post_type ) {
    Severity: Minor
    Found in app/Database/Repository/WordPressPost.php - About 1 hr to fix

      Function findOffset has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function findOffset(root: Element, ss: number): Offset {
        let container;
        let offset = 0;
        let element: ChildNode | null = root;
      
      
      Severity: Minor
      Found in client/components/Editor/findOffset.ts - About 1 hr to fix

        Function refback has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          ref$.flatMap(el => {
            const keyUp$ = Kefir.fromEvents<KeyboardEvent, never>(el, 'keyup').setName(
              'keyUp$',
            );
            const keyDown$ = Kefir.fromEvents<KeyboardEvent, never>(
        Severity: Minor
        Found in client/components/Editor/Code.tsx - About 1 hr to fix

          Function process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function process() {
                  if ( $this->is_running() ) {
                      return new WP_Error(
                          'job_running',
                          sprintf(
          Severity: Minor
          Found in app/Jobs/AbstractJob.php - About 1 hr to fix

          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 find_by has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function find_by( $class, array $params = array() ) {
                  global $wpdb;
                  $models = new Collection( $class );
          
                  $query = "SELECT * FROM {$this->em->make_table_name( $class )}";
          Severity: Minor
          Found in app/Database/Repository/WordPressCustomTable.php - About 1 hr to fix

            Function reducer has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const reducer = (
              state: State,
              action: RootAction,
            ): State | EddyResult<State, RootAction> => {
              switch (state.status) {
            Severity: Minor
            Found in client/block/SetEmbed/index.tsx - About 1 hr to fix

              Method post_type_gistpen has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function post_type_gistpen() {
                      $labels = array(
                          'name'               => _x( 'Gistpens', 'Post Type General Name', 'wp-gistpen' ),
                          'singular_name'      => _x( 'Gistpen', 'Post Type Singular Name', 'wp-gistpen' ),
                          'menu_name'          => __( 'Gistpens', 'wp-gistpen' ),
              Severity: Minor
              Found in app/Register/Data.php - About 1 hr to fix

                Function entity_matches_gist has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function entity_matches_gist( $entity, $gist ) {
                        if ( $entity['description'] !== $gist->description ) {
                            return false;
                        }
                
                
                Severity: Minor
                Found in app/Jobs/ExportJob.php - About 1 hr to fix

                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 13 (exceeds 5 allowed). Consider refactoring.
                Open

                const setSelectionRange = (node: Element, cursor: Cursor) =>
                  Kefir.stream<never, never>(emitter => {
                    if (node !== document.activeElement || cursor == null) {
                      return emitter.end();
                    }
                Severity: Minor
                Found in client/editor/Code.tsx - About 1 hr to fix

                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 process has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function process() {
                        if ( $this->is_running() ) {
                            return new WP_Error(
                                'job_running',
                                sprintf(
                Severity: Minor
                Found in app/Jobs/AbstractJob.php - About 1 hr to fix

                  Method update_to_1_0_0 has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function update_to_1_0_0() {
                          require_once ABSPATH . 'wp-admin/includes/upgrade.php';
                  
                          $runs_table     = $this->em->make_table_name( \Intraxia\Gistpen\Model\Run::class );
                          $messages_table = $this->em->make_table_name( \Intraxia\Gistpen\Model\Message::class );
                  Severity: Minor
                  Found in app/Listener/Migration.php - About 1 hr to fix

                    Method sanitize_prism has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function sanitize_prism( array $prism ) {
                            foreach ( $prism as $key => $value ) {
                                if ( ! array_key_exists( $key, Site::$defaults['prism'] ) ) {
                                    return new WP_Error(
                                        'invalid_rest_param',
                    Severity: Minor
                    Found in app/Http/Filter/SitePatch.php - About 1 hr to fix

                      Method validate_data has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function validate_data( $class, $data ) {
                              switch ( $class ) {
                                  case \Intraxia\Gistpen\Model\Run::class:
                                      if ( isset( $data['items'] ) ) {
                                          $data['items'] = maybe_serialize( $data['items'] );
                      Severity: Minor
                      Found in app/Database/Repository/WordPressCustomTable.php - About 1 hr to fix

                        Function update_gist_for_repo has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function update_gist_for_repo( Repo $repo, stdClass $gist ) {
                                $entity = $this->map_repo_to_new_entity( $repo );
                        
                                if ( $this->entity_matches_gist( $entity, $gist ) ) {
                                    $this->log(
                        Severity: Minor
                        Found in app/Jobs/ExportJob.php - About 1 hr to fix

                        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 find_by has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function find_by( $class, array $params = array() ) {
                                global $wpdb;
                                $models = new Collection( $class );
                        
                                $query = "SELECT * FROM {$this->em->make_table_name( $class )}";
                        Severity: Minor
                        Found in app/Database/Repository/WordPressCustomTable.php - About 1 hr to fix

                        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 reducer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const reducer: EddyReducer<State, RootAction> = (
                          state: State = initialState,
                          action: RootAction,
                        ) => {
                          switch (action.type) {
                        Severity: Minor
                        Found in client/search/state.tsx - About 1 hr to fix

                        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 filter_unregistered_params has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function filter_unregistered_params( $response, $handler, WP_REST_Request $request ) {
                                if ( strpos( $request->get_route(), 'intraxia/v1/gistpen' ) === false ) {
                                    return $response;
                                }
                        
                        
                        Severity: Minor
                        Found in app/Http/StrictParams.php - About 1 hr to fix

                          Method taxonomy_language has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function taxonomy_language() {
                          
                                  $labels       = array(
                                      'name'                       => _x( 'Languages', 'Taxonomy General Name', 'wp-gistpen' ),
                                      'singular_name'              => _x( 'Language', 'Taxonomy Singular Name', 'wp-gistpen' ),
                          Severity: Minor
                          Found in app/Register/Data.php - About 1 hr to fix

                            Method apply_globals has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function apply_globals( $params ) {
                                    $languages = $this->config->get_json_resource( 'languages' );
                            
                                    $params['globals'] = array(
                                        'languages'  => $languages['list'],
                            Severity: Minor
                            Found in app/Params/Globals.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language