HabitatMap/AirCasting

View on GitHub

Showing 667 of 667 total issues

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

interface ButtonProps {
  onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
  children: string | JSX.Element | (JSX.Element | string)[];
}
Severity: Major
Found in app/javascript/react/components/Button/Button.tsx and 1 other location - About 1 hr to fix
app/javascript/react/components/ActionButton/ActionButton.tsx on lines 5..8

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

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

type DormantMarkersProps = {
  sessions: Session[];
  onMarkerClick: (streamId: number | null, id: number | null) => void;
  selectedStreamId: number | null;
  pulsatingSessionId: number | null;
app/javascript/react/components/Map/Markers/MobileMarkers.tsx on lines 22..27

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

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

type Props = {
  sessions: Session[];
  onMarkerClick: (streamId: number | null, id: number | null) => void;
  selectedStreamId: number | null;
  pulsatingSessionId: number | null;
app/javascript/react/components/Map/Markers/DormantMarkers.tsx on lines 25..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 65.

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

interface ButtonProps {
  onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
  children: string | JSX.Element | (JSX.Element | string)[];
}
app/javascript/react/components/Button/Button.tsx on lines 5..8

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

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

    fetch: function (values = {}) {
      if (params.isSessionSelected()) return;
      const limit = values.amount || 100;
      const offset = values.fetchedSessionsCount || 0;

Severity: Minor
Found in app/javascript/javascript/fixedSessions.js - About 1 hr to fix

    Function googleMaps has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const googleMaps = () => {
      let onPanOrZoomHandle;
      let onPanOrZoomCallback = () => {};
    
      const unlistenPanOrZoom = (mapObj) =>
    Severity: Minor
    Found in app/javascript/javascript/googleMaps.js - About 1 hr to fix

      Function filterTimestamps has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const filterTimestamps = (
        timestamps: { [timestamp: string]: any },
        timeRange: TimeRanges
      ): string[] => {
        const now = moment.utc();
      Severity: Minor
      Found in app/javascript/react/utils/filterTimelapseData.ts - About 1 hr to fix

        Method perform has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def perform
            alerts = ThresholdAlert.all
            Sidekiq.logger.info "[TRSHLD] #{alerts.count} alerts found: #{alerts.inspect}"
        
            alerts.each do |alert|
        Severity: Minor
        Found in app/workers/threshold_alerts_worker.rb - About 1 hr to fix

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

              const queryString = Object.keys(query)
                .map(
                  (key) =>
                    `${encodeParamName(key)}=${encodeURIComponent(String(query[key]))}`
                )
          Severity: Major
          Found in app/javascript/react/api/apiEndpoints.ts and 1 other location - About 1 hr to fix
          app/javascript/react/api/apiEndpoints.ts on lines 106..111

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

          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={onPreviousStep} disabled={currentStep === 0}>
                  <img src={skipLeftButton} alt={t("timelapse.altSkipLeft")} />
                </S.NavigationButton>
          app/javascript/react/components/Modals/TimelapseModal/NavigationButtons.tsx on lines 68..70

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

          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={onGoToStart} disabled={currentStep === 0}>
                  <img src={rewindButton} alt={t("timelapse.altRewind")} />
                </S.NavigationButton>
          app/javascript/react/components/Modals/TimelapseModal/NavigationButtons.tsx on lines 71..73

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

          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

              const queryString = Object.keys(query)
                .map(
                  (key) =>
                    `${encodeParamName(key)}=${encodeURIComponent(String(query[key]))}`
                )
          Severity: Major
          Found in app/javascript/react/api/apiEndpoints.ts and 1 other location - About 1 hr to fix
          app/javascript/react/api/apiEndpoints.ts on lines 168..173

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

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

              (isIndoor: string) => {
                if (isMobile) {
                  setUrlParams([
                    {
                      key: UrlParamsTypes.isIndoor,
          Severity: Minor
          Found in app/javascript/react/utils/mapParamsHandler.ts - About 1 hr to fix

            Function getClusterPixelPosition has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const getClusterPixelPosition = (
              map: google.maps.Map,
              latLng: google.maps.LatLng
            ) => {
              const zoom = map.getZoom();
            Severity: Minor
            Found in app/javascript/react/utils/getClusterPixelPosition.ts - About 1 hr to fix

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

              const UniformDistributionButton: React.FC<UniformDistributionButtonProps> = ({
                variant = ThresholdButtonVariant.IconOnly,
                uniformDistributionButtonText,
                swapIconTextPosition = false,
                useDarkBlueIcon = false,

              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

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

                    expected = {
                      'fetchableSessionsCount' => 1,
                      'sessions' => [
                        {
                          'id' => active_session.id,
              spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 258..284

              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

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

                    expected = {
                      'fetchableSessionsCount' => 1,
                      'sessions' => [
                        {
                          'id' => active_session.id,
              spec/controllers/api/fixed/active/sessions_controller_spec.rb on lines 167..193

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

                  fetch: function (values = {}) {
                    if (params.isSessionSelected()) return;
                    const limit = values.amount || 100;
                    const offset = values.fetchedSessionsCount || 0;
              
              
              Severity: Minor
              Found in app/javascript/javascript/mobileSessions.js - About 1 hr to fix

                Method sync has 35 lines of code (exceeds 25 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

                  Method as_json has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def as_json(opts = nil)
                      opts ||= {}
                  
                      methods = opts[:methods] || %i[notes]
                      methods << :type
                  Severity: Minor
                  Found in app/models/session.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language