strikeentco/geo-nearby

View on GitHub

Showing 14 of 14 total issues

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

  nearBy(lat, lon, radius) {
    const limit = this._limit;
    this._limit = this._constLimit;

    if (isGeoJSON(this.data)) {
Severity: Minor
Found in main.js - 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 createCompactSet has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.createCompactSet = (data, opts) => {
  if (typeof data === 'string') {
    try {
      data = JSON.parse(data);
    } catch (e) {
Severity: Minor
Found in lib/base.js - About 1 hr to fix

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

    function searchBetween(set, min, max, limit) {
      const hash = set.hash;
      const data = set.data;
      const result = [];
      const length = data.length;
    Severity: Minor
    Found in lib/base.js - 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 nearBy has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      nearBy(lat, lon, radius) {
        const limit = this._limit;
        this._limit = this._constLimit;
    
        if (isGeoJSON(this.data)) {
    Severity: Minor
    Found in main.js - About 1 hr to fix

      Function createCompactSet has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports.createCompactSet = (data, opts) => {
        if (typeof data === 'string') {
          try {
            data = JSON.parse(data);
          } catch (e) {
      Severity: Minor
      Found in lib/base.js - 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 medianOf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function medianOf(low, mid, high) {
        if (mid.g < low.g) {
          if (high.g < mid.g) {
            return mid;
          }
      Severity: Minor
      Found in lib/sort.js - About 45 mins 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 getCoords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports.getCoords = data => {
        if (data && data.type === 'Point') {
          const coords = data.coordinates;
          if (isArray(coords) && coords.length === 2) {
            const lat = coords[1];
      Severity: Minor
      Found in lib/helpers.js - About 45 mins 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 partition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function partition(items, l, r, x) {
        while (l <= r) {
          while (items[l].g < x.g) {
            l++;
          }
      Severity: Minor
      Found in lib/sort.js - About 35 mins 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 constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        constructor(data, opts) {
          opts = opts || {};
          this.data = data || [];
          this.hash = opts.hash || 'g';
          this.setOptions = opts.setOptions || false;
      Severity: Minor
      Found in main.js - About 35 mins 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

      Avoid too many return statements within this function.
      Open

          return nearBy(this, { lat, lon, radius });
      Severity: Major
      Found in main.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return nearBy(this, { lat, lon, radius, limit }).slice(0, limit);
        Severity: Major
        Found in main.js - About 30 mins to fix

          Function isGeoJSON has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.isGeoJSON = data => {
            if (data) {
              if (data.type) {
                if (geoTypes[data.type]) {
                  return true;
          Severity: Minor
          Found in lib/helpers.js - About 25 mins 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 binarySearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.binarySearch = (set, needle, low, high, max) => {
            const hash = set.hash;
            const data = set.data;
          
            while (low <= high) {
          Severity: Minor
          Found in lib/helpers.js - About 25 mins 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 downHeap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function downHeap(items, k, n) {
            const item = items[k];
            let child;
          
            while ((child = 2 * k + 1) < n) { // eslint-disable-line no-cond-assign
          Severity: Minor
          Found in lib/sort.js - About 25 mins 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