intraxia/wp-gistpen

View on GitHub

Showing 137 of 273 total issues

Method create has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create( $class, array $data = array(), array $options = array() ) {
        $model = new $class();

        /**
         * Set aside the `blobs` key for use.
Severity: Major
Found in app/Database/Repository/WordPressPost.php - About 2 hrs to fix

    Function fill_relations has a Cognitive Complexity of 18 (exceeds 5 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 2 hrs 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 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function find_by( $class, array $params = array() ) {
            $post_type     = $class::get_post_type();
            $parent_search = 'post_parent__in';
    
            if ( Blob::class === $class ) {
    Severity: Major
    Found in app/Database/Repository/WordPressPost.php - About 2 hrs to fix

      Method __construct has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct( Container $container ) {
              $this->container    = $container;
              $this->asset_config = [
                  'edit'     => [
                      'type'      => 'admin',
      Severity: Major
      Found in app/Register/Assets.php - About 2 hrs to fix

        Method add_commit has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function add_commit( Repo $repo ) {
                $commits = $this->em->find_by( Commit::class, array(
                    'repo_id' => $repo->ID,
                    'with'    => array(
                        'states' => array(
        Severity: Major
        Found in app/Listener/Database.php - About 2 hrs to fix

          Function find has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs 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 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const reducer: EddyReducer<State, EditorAction> = (
            state = initialState,
            action,
          ) => {
            switch (action.type) {
          Severity: Major
          Found in client/editor/state.tsx - About 2 hrs to fix

            Method apply_editor has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function apply_editor( $params ) {
                    /**
                     * Returned model.
                     *
                     * @var RepoModel
            Severity: Major
            Found in app/Params/Editor.php - About 2 hrs to fix

              File E2ECommand.tsx has 257 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import path from 'path';
              import { Command } from 'brookjs-cli';
              import { ofType, useDelta, Delta, sampleByAction } from 'brookjs';
              import { Box, Color, AppContext } from 'ink';
              import Kefir, { Observable } from 'kefir';
              Severity: Minor
              Found in commands/E2ECommand.tsx - About 2 hrs to fix

                File AbstractJob.php has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace Intraxia\Gistpen\Jobs;
                
                use Intraxia\Gistpen\Contract\Job;
                Severity: Minor
                Found in app/Jobs/AbstractJob.php - About 2 hrs to fix

                  File jobsDelta.ts has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import Kefir, { Observable, Stream, Property } from 'kefir';
                  import { ofType } from 'brookjs';
                  import * as t from 'io-ts';
                  import { Nullable } from 'typescript-nullable';
                  import { ajax$ } from 'kefir-ajax';
                  Severity: Minor
                  Found in client/deltas/jobsDelta.ts - About 2 hrs to fix

                    Function sanitize_prism has a Cognitive Complexity of 16 (exceeds 5 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 2 hrs 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 selectSelectionStart has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function selectSelectionStart(node: Element): number {
                      const selection = window.getSelection();
                    
                      if (selection && selection.rangeCount) {
                        const range = selection.getRangeAt(0);
                    Severity: Minor
                    Found in client/editor/dom.ts - About 2 hrs 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 selectSelectionStart has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function selectSelectionStart(node: Element): number {
                      const selection = getSelection();
                    
                      if (selection && selection.rangeCount) {
                        const range = selection.getRangeAt(0);
                    Severity: Minor
                    Found in client/selectors/dom.ts - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function find_by( $class, array $params = array() ) {
                            $post_type     = $class::get_post_type();
                            $parent_search = 'post_parent__in';
                    
                            if ( Blob::class === $class ) {
                    Severity: Minor
                    Found in app/Database/Repository/WordPressPost.php - About 2 hrs 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 update_gist_for_repo has 52 lines of code (exceeds 25 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: Major
                    Found in app/Jobs/ExportJob.php - About 2 hrs to fix

                      Method update has 49 lines of code (exceeds 25 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 );
                      
                      
                      Severity: Minor
                      Found in app/Http/BlobController.php - About 1 hr to fix

                        Function rootDelta has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const rootDelta: Delta<RootAction, State> = (action$, state$) => {
                          const createRepo$ = state$
                            .thru(sampleByAction(action$, createRepo.request))
                            .filter((state): state is NewRepoState => state.status === 'create-new')
                            .flatMapFirst(state =>
                        Severity: Minor
                        Found in client/block/SetEmbed/Creating/delta.tsx - About 1 hr to fix

                          Method update_repo_for_gist has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function update_repo_for_gist( Repo $repo, stdClass $gist ) {
                                  $repo->unguard();
                                  $repo->sync        = 'on';
                                  $repo->description = $gist->description;
                                  $repo->status      = true === $gist->public ? 'publish' : 'private';
                          Severity: Minor
                          Found in app/Jobs/ImportJob.php - About 1 hr to fix

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

                            export function findOffset(root: Element, ss: number): Offset {
                              // @TODO(mAAhaTTah) these types seem sketchy...
                              let container;
                              let offset = 0;
                              let element: ChildNode | null = root;
                            Severity: Minor
                            Found in client/editor/dom.ts - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language