cyclejs/cycle-core

View on GitHub

Showing 188 of 188 total issues

Function renderNodeLabel has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function renderNodeLabel(node: StreamGraphNode, zap: Zap | null, style: string): VNode {
  let label = '';
  if (zap) {
    // MUTATION!
    if (Array.isArray(zap.value)) {
Severity: Minor
Found in devtool/src/panel/graph/view.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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

export interface Engine<D extends Drivers> {
  sources: Sources<D>;
  run<M extends MatchingMain<D, M>>(sinks: Sinks<M>): DisposeFunction;
  dispose(): void;
}
Severity: Major
Found in run/src/types.ts and 2 other locations - About 2 hrs to fix
most-run/src/index.ts on lines 49..53
rxjs-run/src/index.ts on lines 50..54

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function comparator has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const comparator = (a: any) => (b: any) => {
  if (a.time < b.time) {
    return -1;
  }

Severity: Minor
Found in time/src/scheduler.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      class: {
        [styles.sourceOrSinkNodeStyle]: !zap,
        [styles.nodeZapNextStyle]: zap && zap.type === 'next',
        [styles.nodeZapErrorStyle]: zap && zap.type === 'error',
        [styles.nodeZapCompleteStyle]: zap && zap.type === 'complete',
Severity: Major
Found in devtool/src/panel/graph/view.ts and 1 other location - About 2 hrs to fix
devtool/src/panel/graph/view.ts on lines 131..136

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      class: {
        [styles.activeNodeStyle]: !zap,
        [styles.nodeZapNextStyle]: zap && zap.type === 'next',
        [styles.nodeZapErrorStyle]: zap && zap.type === 'error',
        [styles.nodeZapCompleteStyle]: zap && zap.type === 'complete',
Severity: Major
Found in devtool/src/panel/graph/view.ts and 1 other location - About 2 hrs to fix
devtool/src/panel/graph/view.ts on lines 84..89

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File app.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import xs from 'xstream'
import debounce from 'xstream/extra/debounce'
import dropUntil from 'xstream/extra/dropUntil'
import {ul, li, span, input, div, section, label} from '@cycle/dom'
import Immutable from 'immutable'
Severity: Minor
Found in examples/advanced/autocomplete-search/src/app.js - About 2 hrs to fix

    File view.ts has 257 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {VNode, svg} from '@cycle/dom';
    import {StreamGraphNode, StreamGraphEdge, Zap} from '../../graphSerializer';
    import styles from './styles';
    
    export const DIAGRAM_PADDING_H = 30;
    Severity: Minor
    Found in devtool/src/panel/graph/view.ts - About 2 hrs to fix

      Function DOMDriver has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function DOMDriver(vnode$: Stream<VNode>, name = 'DOM'): MainDOMSource {
          domDriverInputGuard(vnode$);
          const sanitation$ = xs.create<null>();
      
          const firstRoot$ = domReady$.map(() => {
      Severity: Major
      Found in dom/src/makeDOMDriver.ts - About 2 hrs to fix

        Function makeScheduler has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function makeScheduler<T>(): Schedule<T> {
          let schedule: Array<any> = [];
        
          function getSchedule() {
            return schedule;
        Severity: Major
        Found in time/src/scheduler.ts - About 2 hrs to fix

          Function instances$ has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                (acc: InternalInstances<Si>, nextState: Array<any> | any) => {
                  const dict = acc.dict;
                  if (Array.isArray(nextState)) {
                    const nextInstArray = Array(nextState.length) as Array<
                      Si & {_key: string}
          Severity: Minor
          Found in state/src/Collection.ts - About 2 hrs to fix

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

              public createModule() {
                const self = this;
                return {
                  create(emptyVNode: VNode, vNode: VNode) {
                    const {elm, data = {}} = vNode;
            Severity: Minor
            Found in dom/src/IsolateModule.ts - About 1 hr to fix

              Function runRealtime has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function runRealtime(
                scheduler: any,
                frameCallbacks: any,
                currentTime: () => number,
                setTime: (t: number) => void
              Severity: Minor
              Found in time/src/time-driver.ts - About 1 hr to fix

                Function addEventListener has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  public addEventListener(
                    eventType: string,
                    namespace: Array<Scope>,
                    options: EventsFnOptions,
                    bubbles?: boolean
                Severity: Minor
                Found in dom/src/EventDelegator.ts - 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 renderSourceOrSinkNode has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function renderSourceOrSinkNode(node: StreamGraphNode, zaps: Array<Zap>) {
                  const index = zaps.map(zap => zap.id).indexOf(node.id);
                  const zap = index === -1 ? null : zaps[index];
                  const P = 5; // text padding
                  const hook = {
                Severity: Minor
                Found in devtool/src/panel/graph/view.ts - About 1 hr to fix

                  Function scrollagent has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    $.fn.scrollagent = function(options, callback) {
                      // Account for $.scrollspy(function)
                      if (typeof callback === 'undefined') {
                        callback = options;
                        options = {};
                  Severity: Minor
                  Found in docs/theme/script.js - About 1 hr to fix

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

                    function main(sources: any) {
                      const {DOM, Time} = sources;
                    
                      const speed$ = DOM.select('.speed')
                        .events('input')
                    Severity: Minor
                    Found in time/example/index.ts - About 1 hr to fix

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

                        private bubble(
                          eventType: string,
                          elm: Element,
                          rootElement: Element | undefined,
                          event: CycleDOMEvent,
                      Severity: Minor
                      Found in dom/src/EventDelegator.ts - About 1 hr to fix

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          if (reqOptions.headers) {
                            for (const key in reqOptions.headers) {
                              if (reqOptions.headers.hasOwnProperty(key)) {
                                request = request.set(key, reqOptions.headers[key]);
                              }
                        Severity: Major
                        Found in http/src/http-driver.ts and 1 other location - About 1 hr to fix
                        http/src/http-driver.ts on lines 69..75

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 71.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          if (reqOptions.field) {
                            for (const key in reqOptions.field) {
                              if (reqOptions.field.hasOwnProperty(key)) {
                                request = request.field(key, reqOptions.field[key]);
                              }
                        Severity: Major
                        Found in http/src/http-driver.ts and 1 other location - About 1 hr to fix
                        http/src/http-driver.ts on lines 62..68

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 71.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

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

                        function instanceLens(
                          itemKey: ItemKeyFn<any>,
                          key: string
                        ): Lens<Array<any>, any> {
                          return {
                        Severity: Minor
                        Found in state/src/Collection.ts - 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

                        Severity
                        Category
                        Status
                        Source
                        Language