airbnb/superset

View on GitHub
superset-frontend/plugins/legacy-plugin-chart-map-box/src/ScatterPlotGlowOverlay.jsx

Summary

Maintainability
D
3 days
Test Coverage

Function redraw has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

  redraw({ width, height, ctx, isDragging, project }) {
    const {
      aggregation,
      compositeOperation,
      dotRadius,

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

  redraw({ width, height, ctx, isDragging, project }) {
    const {
      aggregation,
      compositeOperation,
      dotRadius,

    Function _forEach has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          locations.forEach(function _forEach(location, i) {
            const pixel = project(lngLatAccessor(location));
            const pixelRounded = [
              roundDecimal(pixel[0], 1),
              roundDecimal(pixel[1], 1),

      Function drawText has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        drawText(ctx, pixel, options = {}) {
          const IS_DARK_THRESHOLD = 110;
          const {
            fontHeight = 0,
            label = '',

        Avoid deeply nested control flow statements.
        Open

                      if (clusterLabel >= 10000) {
                        clusterLabel = `${Math.round(clusterLabel / 1000)}k`;
                      } else if (clusterLabel >= 1000) {
                        clusterLabel = `${Math.round(clusterLabel / 100) / 10}k`;
                      }

          Avoid deeply nested control flow statements.
          Open

                        if (pointRadiusUnit === 'Kilometers') {
                          pointLabel = `${roundDecimal(pointRadius, 2)}km`;
                          pointRadius = kmToPixels(pointRadius, pointLatitude, zoom);
                        } else if (pointRadiusUnit === 'Miles') {
                          pointLabel = `${roundDecimal(pointRadius, 2)}mi`;

            Avoid too many return statements within this function.
            Open

              return count;

              Avoid too many return statements within this function.
              Open

                  return Math.round(100 * Math.sqrt(variance)) / 100;

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

                const computeClusterLabel = (properties, aggregation) => {
                  const count = properties.point_count;
                  if (!aggregation) {
                    return count;
                  }

                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 6 locations. Consider refactoring.
                Open

                    const {
                      aggregation,
                      compositeOperation,
                      dotRadius,
                      lngLatAccessor,
                superset-frontend/plugins/legacy-plugin-chart-horizon/src/HorizonRow.jsx on lines 84..94
                superset-frontend/src/dashboard/components/DashboardGrid.jsx on lines 183..193
                superset-frontend/src/dashboard/components/dnd/DragDroppable.jsx on lines 148..158
                superset-frontend/src/dashboard/components/resizable/ResizableContainer.jsx on lines 202..212
                superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx on lines 630..640

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

                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

                There are no issues that match your filters.

                Category
                Status