Skip to content

Commit

Permalink
SonarQube fixes + localisation of Route Details
Browse files Browse the repository at this point in the history
  • Loading branch information
datKaMa committed Feb 6, 2025
1 parent 3b6ad4b commit cd3b171
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 54 deletions.
2 changes: 1 addition & 1 deletion packages/plugins/Routing/src/components/Routing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export default Vue.extend({
localKey: 'common:plugins.routing.avoidRoutes.ferries',
},
]
}['']
}
return availableOptions
},
areFieldsMissing() {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/Routing/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue'
import { RoutingConfiguration } from '@polar/lib-custom-types' // TODO: Merken: Wird erst nach mergen des PR aktualisiert
import { RoutingConfiguration } from '@polar/lib-custom-types'
import { makeStoreModule } from './store'
import { Routing } from './components'
import language from './language'
Expand Down
4 changes: 4 additions & 0 deletions packages/plugins/Routing/src/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const language: LanguageOption[] = [
toolTip:
'Pflichtfelder: Startadresse, Zieladresse, Fortbewegungsart und bevorzugte Route.',
routeDetails: 'Details zur Route',
distance: 'Entfernung:',
duration: 'Dauer:',
},
},
},
Expand Down Expand Up @@ -82,6 +84,8 @@ const language: LanguageOption[] = [
toolTip:
'Required: Start Address, Destination Address, Travel Mode and Preferred Route.',
routeDetails: 'Route Details',
distance: 'Distance:',
duration: 'Duration:',
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions packages/plugins/Routing/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,16 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
* @param responseText - XML response text.
* @returns Parsed house numbers data.
*/
// empty action context is necessary here
// eslint-disable-next-line no-empty-pattern
parseResponseHausnummern({}, responseText) {

Check failure on line 220 in packages/plugins/Routing/src/store/actions.ts

View workflow job for this annotation

GitHub Actions / lint

Method 'parseResponseHausnummern' has too many lines (51). Maximum allowed is 50
try {
const parser = new DOMParser()
const xmlDoc = parser.parseFromString(responseText, 'application/xml')
const members = xmlDoc.getElementsByTagName('wfs:member')
const features: SearchResponseDataInterface[] = []

for (let i = 0; i < members.length; i++) {
const member = members[i]
for (const member of members) {
const hauskoordinaten = member.getElementsByTagName(
'gages:Hauskoordinaten'
)[0]
Expand Down Expand Up @@ -282,8 +283,7 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
const members = xmlDoc.getElementsByTagName('wfs:member')
const features: FeatureInterface[] = []

for (let i = 0; i < members.length; i++) {
const member = members[i]
for (const member of members) {
const strasseElement = member.getElementsByTagName('dog:Strassen')[0]

if (strasseElement) {
Expand All @@ -307,8 +307,8 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {

const hausnummerElements =
strasseElement.getElementsByTagName('dog:hausnummer')
for (let j = 0; j < hausnummerElements.length; j++) {
hausnummern.push(hausnummerElements[j].textContent)
for (const hausnummer of hausnummerElements) {
hausnummern.push(hausnummer.textContent)
}

features.push({
Expand Down
45 changes: 0 additions & 45 deletions packages/plugins/Routing/src/tests/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,51 +130,6 @@ describe('plugin-routing', () => {
clickHandler({ coordinate: [20, 60] })
expect(actionContext.commit).toHaveBeenCalledWith('setEnd', [20, 60])
})
/*
it('should not set end point if it matches start point', () => {
let clickHandler
actionContext.rootGetters.map.on = jest.fn((event, handler) => {
if (event === 'click') clickHandler = handler
})
// @ts-ignore
initializeTool(actionContext)
if (!clickHandler) throw new Error('Click handler was not set')
console.error('Initial state:', actionContext.state)
console.error(
'Map event listeners:',
actionContext.rootGetters.map.on.mock.calls
)
console.error('Commits before click:', actionContext.commit.mock.calls)
// Simulate first click (start point)
clickHandler({ coordinate: [10, 50] })
console.error("Commits after first click:", actionContext.commit.mock.calls);
console.error("State after first click:", actionContext.state);
expect(actionContext.commit).toHaveBeenCalledWith(
expect.stringMatching(/setStart/),
expect.arrayContaining([10, 50])
)
// Simulate a second click on the same coordinate
clickHandler({ coordinate: [10, 50] })
expect(actionContext.commit).not.toHaveBeenCalledWith(
'setEnd',
[10, 50]
)
const calls = actionContext.commit.mock.calls.map((call) => call[0])
expect(calls).toEqual([
'setSelectableTravelModes',
'setSelectablePreferences',
'setDisplayPreferences',
'setDisplayRouteTypesToAvoid',
'setStart',
])
}) */
})
describe('resetCoordinates', () => {
const routingStore = makeStoreModule()
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/Routing/src/utils/createDrawLayer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import VectorLayer from 'ol/layer/Vector'
import { Stroke, Style } from 'ol/style'
import { RouteStyle } from '@polar/lib-custom-types' // TODO: routeStyle aus der mapConfig?
import { RouteStyle } from '@polar/lib-custom-types'
import { PolarVectorOptions } from '../types'

/**
Expand Down

0 comments on commit cd3b171

Please sign in to comment.