HabitatMap/AirCasting

View on GitHub

Showing 667 of 667 total issues

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

const TimeRangeButtons = () => {
  const timeRange = useAppSelector(selectTimelapseTimeRange);
  const { t } = useTranslation();
  const dispatch = useAppDispatch();

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

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

      Function preprocessData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var preprocessData = function (data, sessions) {
          var times;
      
          _(data).each(function (session) {
            if (session.start_time_local && session.end_time_local) {
      Severity: Minor
      Found in app/javascript/javascript/sessionsDownloader.js - About 1 hr to fix

        Method call has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def call
            {
              title: session.title,
              username: session.is_indoor ? 'anonymous' : session.user.username,
              sensorName: stream.sensor_name,
        Severity: Minor
        Found in app/services/api/to_fixed_session_hash.rb - About 1 hr to fix

          Function centerMapOnBounds has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              (
                minLatitude: number,
                maxLatitude: number,
                minLongitude: number,
                maxLongitude: number
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/MobileMarkers.tsx - About 1 hr to fix

            Method save has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def save(streams)
                persisted_streams =
                  Stream
                    .select(:id, :min_latitude, :min_longitude, :sensor_name, :session_id)
                    .joins(:session)
            Severity: Minor
            Found in app/services/save_measurements.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 CopyLinkComponent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            const CopyLinkComponent = ({
              button,
              isIconOnly,
              showBelowButton,
              onOpen,
            Severity: Minor
            Found in app/javascript/react/components/Popups/CopyLinkComponent.tsx - 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 CustomSensorFilter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            const CustomSensorFilter: React.FC<CustomSensorFilterProps> = ({
              customSensors,
              sessionsCount = 0,
              onClose = () => {},
              fetchableSessionsCount,

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

            export const getBasicSensors = (
              measurementType: string,
              sessionType: string
            ) => {
              if (measurementType !== ParameterTypes.PARTICULATE_MATTER) {
            Severity: Minor
            Found in app/javascript/react/components/SessionFilters/SensorFilter.tsx - 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 CustomParameterFilter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            const CustomParameterFilter: React.FC<CustomParameterFilterProps> = ({
              customParameters,
              sessionsCount = 0,
              onClose = () => {},
              fetchableSessionsCount,

            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

                      {
                        'stream_id' => other_stream.id,
                        'sensor_name' => other_stream.sensor_name,
                        'last_measurement_value' => other_stream.average_value,
                        'max_latitude' => 1.0,
            Severity: Major
            Found in spec/controllers/api/fixed/sessions_controller_spec.rb and 1 other location - About 1 hr to fix
            spec/controllers/api/fixed/sessions_controller_spec.rb on lines 37..61

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

            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

                      {
                        'stream_id' => stream.id,
                        'sensor_name' => stream.sensor_name,
                        'last_measurement_value' => stream.average_value,
                        'max_latitude' => 1.0,
            Severity: Major
            Found in spec/controllers/api/fixed/sessions_controller_spec.rb and 1 other location - About 1 hr to fix
            spec/controllers/api/fixed/sessions_controller_spec.rb on lines 63..87

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

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

              def build_measurements!(data = [])
                data = data.map(&:deep_symbolize_keys)
                factory = RGeo::Geographic.spherical_factory(srid: 4326)
                time_zone = time_zone(data)
            
            
            Severity: Minor
            Found in app/models/stream.rb - About 1 hr to fix

              Function setStartDate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  setStartDate: function (startDate) {
                    if (typeof startDate === "string")
                      this.startDate = moment(startDate, this.locale.format);
              
                    if (typeof startDate === "object") this.startDate = moment(startDate);
              Severity: Minor
              Found in app/javascript/jquery.ui.daterangepicker.js - About 1 hr to fix

                Function useShortenedLink has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const useShortenedLink = (url: string, accessToken: string) => {
                  const [shortenedLink, setShortenedLink] = useState<string>(url);
                  const [error, setError] = useState<Error | null>(null);
                
                  useEffect(() => {
                Severity: Minor
                Found in app/javascript/react/utils/useShortenedLink.ts - About 1 hr to fix

                  Function show has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      show: function (e) {
                        if (this.isShowing) return;
                  
                        // Create a click proxy that is private to this instance of datepicker, for unbinding
                        this._outsideClickProxy = $.proxy(function (e) {
                  Severity: Minor
                  Found in app/javascript/jquery.ui.daterangepicker.js - About 1 hr to fix

                    Function render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      render: (cluster: Cluster) => {
                        // Accept the entire Cluster object
                        const { count, position, markers = [] } = cluster;
                    
                        const customMarkers = markers as CustomMarker[];

                      Function BackButton has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const BackButton = () => {
                        const { t } = useTranslation();
                        const handleCalendarGoBack = useCalendarBackNavigation();
                      
                        const { previousUserSettings } = useMapParams();
                      Severity: Minor
                      Found in app/javascript/react/components/Navbar/BackButton.tsx - About 1 hr to fix

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

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

                          Function useCalendarBackNavigation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const useCalendarBackNavigation = () => {
                            const navigate = useNavigate();
                            const isMobile = useMobileDetection();
                          
                            const { currentUserSettings, previousUserSettings, searchParams } =
                          Severity: Minor
                          Found in app/javascript/react/hooks/useBackNavigation.tsx - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language