cyclejs/cycle-core

View on GitHub

Showing 188 of 188 total issues

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

export function preventDefaultConditional(
  event: any,
  preventDefault: PreventDefaultOpt
): void {
  if (preventDefault) {
Severity: Minor
Found in dom/src/fromEvent.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 createTagFunction has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function createTagFunction(tagName: string): Function {
  return function hyperscript(a: any, b?: any, c?: any): VNode {
    const hasA = typeof a !== 'undefined';
    const hasB = typeof b !== 'undefined';
    const hasC = typeof c !== 'undefined';
Severity: Minor
Found in dom/src/hyperscript-helpers.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 createResponse$ has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createResponse$(reqInput: RequestInput): Stream<Response> {
  let request: any;
  return xs.create<Response>({
    start: function startResponseStream(listener) {
      try {
Severity: Minor
Found in http/src/http-driver.ts - About 1 hr to fix

    Function clickListener has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      return function clickListener(event: MouseEvent) {
        if (which(event) !== 1) {
          return;
        }
    
    
    Severity: Minor
    Found in history/src/captureClicks.ts - About 1 hr to fix

      Function model has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function model(action$, itemFn) {
        function createRandomItemProps() {
          let hexColor = Math.floor(Math.random() * 16777215).toString(16);
          while (hexColor.length < 6) {
            hexColor = '0' + hexColor;
      Severity: Minor
      Found in examples/advanced/many/src/List.js - About 1 hr to fix

        Function periodic has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          return function periodic(period: number): Stream<number> {
            let stopped = false;
            let lastEmitTime = 0;
        
            function scheduleNextEvent(
        Severity: Minor
        Found in time/src/periodic.ts - About 1 hr to fix

          Function makeChartDriver has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function makeChartDriver(selector, settings) {
            let instance = null // lazy initialize chart on first stream event
            const el = document.querySelector(selector)
            if (!el) {
              throw new Error(`No element '${selector}' found`)
          Severity: Minor
          Found in examples/advanced/custom-driver/src/chart-driver.js - About 1 hr to fix

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

            function main(sources) {
              const changeWeight$ = sources.DOM.select('#weight').events('input')
                .map(ev => ev.target.value);
              const changeHeight$ = sources.DOM.select('#height').events('input')
                .map(ev => ev.target.value);
            Severity: Minor
            Found in examples/basic/bmi-naive/src/main.js - About 1 hr to fix

              Function calculateAnimationSteps has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function calculateAnimationSteps(point$) {
                function incorporateNewPoint(oldPoints, newPoint) {
                  const index = oldPoints.findIndex(point => point.key === newPoint.key)
                  let points
                  if (index === -1 && newPoint.target === 1) {
              Severity: Minor
              Found in examples/advanced/animated-letters/src/main.js - About 1 hr to fix

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

                export type ReplaceHistoryInput = {
                  type: 'replace';
                  pathname: Pathname;
                  search?: Search;
                  state?: any;
                Severity: Major
                Found in history/src/types.ts and 1 other location - About 1 hr to fix
                history/src/types.ts on lines 14..21

                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 61.

                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

                export type PushHistoryInput = {
                  type: 'push';
                  pathname?: Pathname;
                  search?: Search;
                  state?: any;
                Severity: Major
                Found in history/src/types.ts and 1 other location - About 1 hr to fix
                history/src/types.ts on lines 23..30

                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 61.

                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

                export const makeDOMDriver: (
                  sel: string | Element | DocumentFragment,
                  opts?: DOMDriverOptions
                ) => Driver<Stream<VNode>, DOMSource> = make as any;
                Severity: Major
                Found in dom/src/rxjs.ts and 1 other location - About 1 hr to fix
                dom/src/most.ts on lines 19..22

                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 60.

                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

                export const makeDOMDriver: (
                  sel: string | Element | DocumentFragment,
                  opts?: DOMDriverOptions
                ) => Driver<xsStream<VNode>, DOMSource> = make as any;
                Severity: Major
                Found in dom/src/most.ts and 1 other location - About 1 hr to fix
                dom/src/rxjs.ts on lines 19..22

                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 60.

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

                export function setup<
                  D extends MatchingDrivers<D, M>,
                  M extends MatchingMain<D, M>
                >(main: M, drivers: D): CycleProgram<D, M> {
                  if (typeof main !== `function`) {
                Severity: Minor
                Found in run/src/index.ts - About 1 hr to fix

                  Function makeAssertEqual has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function makeAssertEqual(
                    timeSource: any,
                    schedule: any,
                    currentTime: () => number,
                    interval: number,
                  Severity: Minor
                  Found in time/src/assert-equal.ts - About 1 hr to fix

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

                    function main(sources) {
                      // Requests for Github repositories happen when the input field changes,
                      // debounced by 500ms, ignoring empty input field.
                      const searchRequest$ = sources.DOM.select('.field').events('input')
                        .compose(sources.Time.debounce(500))
                    Severity: Minor
                    Found in examples/intermediate/http-search-github/src/main.js - About 1 hr to fix

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

                            if (!inst.dict.has(key) || !inst.dict.get(key)) {
                              il.ins._remove(il);
                              il.ins = null as any;
                              il.out = null as any;
                              ils.delete(key);
                      Severity: Major
                      Found in state/src/pickMerge.ts and 1 other location - About 1 hr to fix
                      state/src/pickMerge.ts on lines 59..64

                      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 59.

                      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

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

                          ils.forEach((il, key) => {
                            il.ins._remove(il);
                            il.ins = null as any;
                            il.out = null as any;
                            ils.delete(key);
                      Severity: Major
                      Found in state/src/pickMerge.ts and 1 other location - About 1 hr to fix
                      state/src/pickMerge.ts on lines 90..95

                      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 59.

                      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

                        const speed$ = DOM.select('.speed')
                          .events('input')
                          .map((ev: any) => ev.target.value)
                          .startWith(maxSpeed / 2);
                      Severity: Major
                      Found in time/example/index.ts and 1 other location - About 1 hr to fix
                      time/example/index.ts on lines 65..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 59.

                      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

                        const height$ = DOM.select('.height')
                          .events('input')
                          .map((ev: any) => ev.target.value)
                          .startWith(maxHeight / 2);
                      Severity: Major
                      Found in time/example/index.ts and 1 other location - About 1 hr to fix
                      time/example/index.ts on lines 60..63

                      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 59.

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language