HabitatMap/AirCasting

View on GitHub

Showing 667 of 667 total issues

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

    builder
      .addCase(fetchDormantFixedSessions.pending, (state) => {
        state.status = StatusEnum.Pending;
        state.error = null;
      })
Severity: Major
Found in app/javascript/react/store/fixedSessionsSlice.ts and 6 other locations - About 1 hr to fix
app/javascript/react/store/fixedSessionsSlice.ts on lines 133..154
app/javascript/react/store/indoorSessionsSlice.ts on lines 109..129
app/javascript/react/store/indoorSessionsSlice.ts on lines 109..149
app/javascript/react/store/mobileSessionsSlice.ts on lines 116..141
app/javascript/react/store/sensorsSlice.ts on lines 63..84
app/javascript/react/store/thresholdSlice.ts on lines 77..105

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

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

    htmlFor: function (data, sessionType) {
      if (!data) {
        return `
          <div class="info-window">
            <div>Contains more than 100 sessions</div>
Severity: Minor
Found in app/javascript/javascript/infoWindow.js - About 1 hr to fix

    Function sessionsDownloader has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const sessionsDownloader = () => {
      var fetch = function (url, reqData, sessions, refreshSessionsCallback) {
        var successCallback = function (data) {
          // data is cached so better not mutate it
          data = JSON.parse(JSON.stringify(data));
    Severity: Minor
    Found in app/javascript/javascript/sessionsDownloader.js - About 1 hr to fix

      Function handleClusteringEnd has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const handleClusteringEnd = useCallback(() => {
          const currentZoom = map?.getZoom() ?? null;
      
          if (currentZoom === previousZoomRef.current) {
            return;
      Severity: Minor
      Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx - About 1 hr to fix

        Function handleMapIdle has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            (event: MapEvent) => {
              const map = event.map;
              if (!mapInstance) {
                setMapInstance(map);
                map.setOptions({
        Severity: Minor
        Found in app/javascript/react/components/Map/Map.tsx - About 1 hr to fix

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

                get :index,
                    params: {
                      q: {
                        time_from:
                          session_time.to_datetime.strftime('%Q').to_i / 1_000 - 1,
          Severity: Major
          Found in spec/controllers/api/mobile/sessions_controller_spec.rb and 4 other locations - About 1 hr to fix
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 38..59
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 146..167
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 319..340
          spec/controllers/api/fixed/dormant/sessions_controller_spec.rb on lines 15..36

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

          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

                <S.NavigationButton
                  onClick={onGoToEnd}
                  disabled={currentStep === totalSteps - 1}
                >
                  <img src={fastForwardButton} alt={t("timelapse.altFastForward")} />
          app/javascript/react/components/Modals/TimelapseModal/NavigationButtons.tsx on lines 80..85

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

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

                get :index2,
                    params: {
                      q: {
                        time_from:
                          session_time.to_datetime.strftime('%Q').to_i / 1_000 - 1,
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 38..59
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 319..340
          spec/controllers/api/fixed/dormant/sessions_controller_spec.rb on lines 15..36
          spec/controllers/api/mobile/sessions_controller_spec.rb on lines 22..43

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

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

                get :index2,
                    params: {
                      q: {
                        time_from:
                          session_time.to_datetime.strftime('%Q').to_i / 1_000 - 1,
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 38..59
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 146..167
          spec/controllers/api/fixed/dormant/sessions_controller_spec.rb on lines 15..36
          spec/controllers/api/mobile/sessions_controller_spec.rb on lines 22..43

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

          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

                <S.NavigationButton
                  onClick={onNextStep}
                  disabled={currentStep === totalSteps - 1}
                >
                  <img src={skipRightButton} alt={t("timelapse.altSkipRight")} />
          app/javascript/react/components/Modals/TimelapseModal/NavigationButtons.tsx on lines 86..91

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

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

                get :index,
                    params: {
                      q: {
                        time_from:
                          session_time.to_datetime.strftime('%Q').to_i / 1_000 - 1,
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 38..59
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 146..167
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 319..340
          spec/controllers/api/mobile/sessions_controller_spec.rb on lines 22..43

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

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

                get :index,
                    params: {
                      q: {
                        time_from:
                          session_time.to_datetime.strftime('%Q').to_i / 1_000 - 1,
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 146..167
          spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 319..340
          spec/controllers/api/fixed/dormant/sessions_controller_spec.rb on lines 15..36
          spec/controllers/api/mobile/sessions_controller_spec.rb on lines 22..43

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

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

          const createHtml = (index) => {
            const data = notes[index].data;
            const date = moment(data.date, "YYYY-MM-DDTHH:mm:ss").format(
              "MM/DD/YYYY, HH:mm:ss"
            );
          Severity: Minor
          Found in app/javascript/javascript/note.js - About 1 hr to fix

            Method change has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def change
                begin
                  change_table :measurements do |t|
                    t.references :stream
                  end
            Severity: Minor
            Found in db/migrate/20120426093113_add_package_name_to_stream.rb - About 1 hr to fix

              Method to_mobile_sessions_array has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def to_mobile_sessions_array(sessions)
                  sessions.map do |session|
                    {
                      id: session.id,
                      title: session.title,
              Severity: Minor
              Found in app/services/api/to_mobile_sessions_array.rb - About 1 hr to fix

                Function extraReducers has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  extraReducers: (builder) => {
                    builder
                      .addCase(fetchActiveIndoorSessions.pending, (state) => {
                        state.status = StatusEnum.Pending;
                        state.error = null;
                Severity: Minor
                Found in app/javascript/react/store/indoorSessionsSlice.ts - About 1 hr to fix

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

                        {viewMode === ViewMode.MAP && (
                          <S.TerrainContainer>
                            <CheckboxButton
                              label={t("map.terrainLabel")}
                              isChecked={isTerrainChecked}
                  app/javascript/react/components/Map/ControlPanel/ControlPanel.tsx on lines 119..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 67.

                  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

                        {viewMode === ViewMode.SATELLITE && (
                          <S.TerrainContainer>
                            <CheckboxButton
                              label={t("map.labelsLabel")}
                              isChecked={isLabelsChecked}
                  app/javascript/react/components/Map/ControlPanel/ControlPanel.tsx on lines 109..117

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

                  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

                  Method sync has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def sync(data)
                      upload = []
                      deleted = []
                  
                      data.each do |session_data|
                  Severity: Minor
                  Found in app/models/user.rb - 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 getXAxisOptions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const getXAxisOptions = (
                    isMobile: boolean,
                    rangeDisplayRef: React.RefObject<HTMLDivElement> | undefined,
                    fixedSessionTypeSelected: boolean,
                    isIndoor: string | null,
                  Severity: Minor
                  Found in app/javascript/react/components/Graph/graphConfig.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