placemark/togeojson

View on GitHub

Showing 24 of 24 total issues

Function getLap has a Cognitive Complexity of 37 (exceeds 10 allowed). Consider refactoring.
Open

function getLap(node: Element): Feature | null {
  const segments = $(node, "Track");
  const track = [];
  const times = [];
  const heartRates = [];
Severity: Minor
Found in lib/tcx.ts - About 4 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 getGeometry has a Cognitive Complexity of 36 (exceeds 10 allowed). Consider refactoring.
Open

export function getGeometry(node: Element): GeometriesAndTimes {
  let geometries: Geometry[] = [];
  let coordTimes: string[][] = [];

  for (let i = 0; i < node.childNodes.length; i++) {
Severity: Minor
Found in lib/kml/geometry.ts - About 4 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 getTrack has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
Open

function getTrack(node: Element): Feature<LineString | MultiLineString> | null {
  const segments = $(node, "trkseg");
  const track = [];
  const times = [];
  const extractedLines = [];
Severity: Minor
Found in lib/gpx.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 getGeometry has 67 lines of code (exceeds 50 allowed). Consider refactoring.
Open

export function getGeometry(node: Element): GeometriesAndTimes {
  let geometries: Geometry[] = [];
  let coordTimes: string[][] = [];

  for (let i = 0; i < node.childNodes.length; i++) {
Severity: Major
Found in lib/kml/geometry.ts - About 1 hr to fix

    Function getLap has 67 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    function getLap(node: Element): Feature | null {
      const segments = $(node, "Track");
      const track = [];
      const times = [];
      const heartRates = [];
    Severity: Major
    Found in lib/tcx.ts - About 1 hr to fix

      Function kmlWithFolders has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
      Open

      export function kmlWithFolders(
        node: Document,
        options: KMLOptions = {
          skipNullGeometry: false,
        }
      Severity: Minor
      Found in lib/kml.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 getTrack has 59 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      function getTrack(node: Element): Feature<LineString | MultiLineString> | null {
        const segments = $(node, "trkseg");
        const track = [];
        const times = [];
        const extractedLines = [];
      Severity: Major
      Found in lib/gpx.ts - About 1 hr to fix

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

                case "LineString": {
                  const coordinates = coord(getCoordinates(child));
                  if (coordinates.length >= 2) {
                    geometries.push({
                      type: "LineString",
        Severity: Major
        Found in lib/kml/geometry.ts and 1 other location - About 1 hr to fix
        lib/kml/geometry.ts on lines 107..116

        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

                case "Point": {
                  const coordinates = coord1(getCoordinates(child));
                  if (coordinates.length >= 2) {
                    geometries.push({
                      type: "Point",
        Severity: Major
        Found in lib/kml/geometry.ts and 1 other location - About 1 hr to fix
        lib/kml/geometry.ts on lines 118..127

        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 function extractLine(node: Element) {
          return get(node, "LineStyle", (lineStyle) => {
            return Object.assign(
              getColor(lineStyle, "stroke"),
              numericProperty(lineStyle, "width", "stroke-width")
        Severity: Major
        Found in lib/kml/extractStyle.ts and 1 other location - About 1 hr to fix
        lib/kml/extractStyle.ts on lines 48..55

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

        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 function extractLabel(node: Element) {
          return get(node, "LabelStyle", (labelStyle) => {
            return Object.assign(
              getColor(labelStyle, "label"),
              numericProperty(labelStyle, "scale", "label-scale")
        Severity: Major
        Found in lib/kml/extractStyle.ts and 1 other location - About 1 hr to fix
        lib/kml/extractStyle.ts on lines 57..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 56.

        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

                case "GroundOverlay": {
                  placemarks.push(node);
                  const placemark = getGroundOverlay(node, styleMap, schema, options);
                  if (placemark) {
                    pointer.children.push(placemark);
        Severity: Major
        Found in lib/kml.ts and 1 other location - About 1 hr to fix
        lib/kml.ts on lines 207..214

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

        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

                case "Placemark": {
                  placemarks.push(node);
                  const placemark = getPlacemark(node, styleMap, schema, options);
                  if (placemark) {
                    pointer.children.push(placemark);
        Severity: Major
        Found in lib/kml.ts and 1 other location - About 1 hr to fix
        lib/kml.ts on lines 199..206

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

        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 getPoints has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
        Open

        function getPoints(node: Element) {
          const pts = $(node, "Trackpoint");
          const line: Position[] = [];
          const times = [];
          const heartRates = [];
        Severity: Minor
        Found in lib/tcx.ts - About 55 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 getPoints has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
        Open

        function getPoints(node: Element, pointname: "trkpt" | "rtept") {
          const pts = $(node, pointname);
          const line: Position[] = [];
          const times = [];
          const extendedValues: P = {};
        Severity: Minor
        Found in lib/gpx.ts - About 55 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

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

        export function tcx(node: Document): FeatureCollection {
          return {
            type: "FeatureCollection",
            features: Array.from(tcxGen(node)),
          };
        Severity: Minor
        Found in lib/tcx.ts and 1 other location - About 50 mins to fix
        lib/gpx.ts on lines 192..197

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

        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 function gpx(node: Document): FeatureCollection {
          return {
            type: "FeatureCollection",
            features: Array.from(gpxGen(node)),
          };
        Severity: Minor
        Found in lib/gpx.ts and 1 other location - About 50 mins to fix
        lib/tcx.ts on lines 200..205

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

        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

        Avoid deeply nested control flow statements.
        Open

                    if (ring.length >= 4) {
                      coords.push(ring);
                    }
        Severity: Major
        Found in lib/kml/geometry.ts - About 45 mins to fix

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

              expect(
                tj.kml(parse(path.join(d, "null_geometry.kml")), {
                  skipNullGeometry: false,
                }).features
              ).toHaveLength(1);
          Severity: Minor
          Found in lib/index.test.ts and 1 other location - About 35 mins to fix
          lib/index.test.ts on lines 42..46

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

          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

              expect(
                tj.kml(parse(path.join(d, "null_geometry.kml")), {
                  skipNullGeometry: true,
                }).features
              ).toHaveLength(0);
          Severity: Minor
          Found in lib/index.test.ts and 1 other location - About 35 mins to fix
          lib/index.test.ts on lines 47..51

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

          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