HabitatMap/AirCasting

View on GitHub

Showing 239 of 667 total issues

Function IndoorOutdoorSwitch has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const IndoorOutdoorSwitch = () => {
  const { t } = useTranslation();
  const { isIndoor, updateIndoorFilters, setFilter } = useMapParams();
  const dispatch = useAppDispatch();

    Function monthOrYearChanged has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        monthOrYearChanged: function (e) {
          var isLeft = $(e.target).closest(".drp-calendar").hasClass("left"),
            leftOrRight = isLeft ? "left" : "right",
            cal = this.container.find(".drp-calendar." + leftOrRight);
    
    
    Severity: Minor
    Found in app/javascript/jquery.ui.daterangepicker.js - About 1 hr to fix

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

        def call
          {
            title: session.title,
            average: stream.measurements.average(:value),
            id: session.id,
      Severity: Minor
      Found in app/services/api/to_session_hash2.rb - About 1 hr to fix

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

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

          Function newRectangles has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                const newRectangles = crowdMapRectangles.map((rectangle) => {
                  const newRectangle = new google.maps.Rectangle({
                    bounds: new google.maps.LatLngBounds(
                      new google.maps.LatLng(rectangle.south, rectangle.west),
                      new google.maps.LatLng(rectangle.north, rectangle.east)
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/CrowdMapMarkers.tsx - About 1 hr to fix

            Method build_json_output has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def build_json_output(anonymous = false)
                sessions = formatted_sessions
                streams = Stream.where(session_id: sessions.pluck('sessions.id'))
                selected_sensor_streams =
                  streams.select do |stream|
            Severity: Minor
            Found in app/services/api/to_active_sessions_json.rb - About 1 hr to fix

              Function createMarkerIcon has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              export const createMarkerIcon = (
                color: string,
                value: string,
                isSelected: boolean = false,
                shouldPulse: boolean
              Severity: Minor
              Found in app/javascript/react/components/Map/Markers/createMarkerIcon.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 MapButtons has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              const MapButtons: React.FC = () => {
                const { goToUserSettings, currentUserSettings, sessionType, isIndoor } =
                  useMapParams();
                const [activeButtons, setActiveButtons] = useState<ButtonTypes[]>([]);
                const [activeCopyLinkButton, setActiveCopyLinkButton] = useState(false);
              Severity: Minor
              Found in app/javascript/react/components/MapButtons/MapButtons.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 handleScrollEnd has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const handleScrollEnd = useCallback(() => {
                  const hasMoreSessions = listSessions.length < fetchableMobileSessionsCount;
                  const hasMoreDormantSessions =
                    isDormant && listSessions.length < fetchableFixedSessionsCount;
              
              
              Severity: Minor
              Found in app/javascript/react/utils/scrollEnd.ts - About 1 hr to fix

                Function setSensorParams has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    (selectedSensor: string, sensors: Sensor[]) => {
                      const commonParams = [
                        {
                          key: UrlParamsTypes.previousUserSettings,
                          value: currentUserSettings,
                Severity: Minor
                Found in app/javascript/react/utils/mapParamsHandler.ts - About 1 hr to fix

                  Function SessionTypeToggle has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const SessionTypeToggle = () => {
                    const dispatch = useAppDispatch();
                    const { searchParams, sessionType, updateSessionType } = useMapParams();
                    const { t } = useTranslation();
                  
                  

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

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

                      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

                              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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language