Showing 252 of 825 total issues
Function wargameListPromise
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
.then(dbList => {
const dbLists = dbList.map(dbName => dbName.replace(dbSuffix, ''))
const wargameDbs = dbLists.filter(name => name.includes('wargame'))
const reversedWargameDbs = wargameDbs.reverse()
const serverPath = `${req.protocol}://${req.get('host')}`
Function setupEditor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const setupEditor = (editor: Editor | null, schema: any, ref: RefObject<HTMLDivElement>,
jsonEditorConfig: Record<string, any>,
showErrorsMode?: string): Editor | null => {
if (editor !== null) {
editor.destroy()
Function initMapListener
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const initMapListener = () => {
let layersVisible = true
map.pm.Toolbar.createCustomControl({
name: 'showLayersText',
block: 'custom',
Function generateRowItemsChat
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const generateRowItemsChat = (forces: ForceData[], nextParticipant: ParticipantChat): RowItem[] => {
let forceSelected: number[] = [0]
let roleOptions: Option[] = []
const additionalFields: RowItem[] = []
Function Wrapper
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Wrapper = (): React.ReactElement => {
const forcesMock = watuWargame.data.forces.forces[0]
const initialState = { types: forcesMock.roles }
const [items, setItems] = useState<{ types: Array<Item> }>(initialState)
Function Template
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Template: StoryFn<MessageListPropTypes> = (args) => {
const { messages, playerForceId, hideForcesInChannel } = args
const icons = [
'./images/default_img/forceDefault.png'
]
Function exportDataGrouped
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
const exportDataGrouped = (messages: Message[], channelTitles: ChannelTitles): ExportItemData[] => {
const data: ExportItemData[] = []
const messageTypes: MessageTypes = {}
for (const message of messages) {
- Read upRead up
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 runServer
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
const runServer = (
pouchOptions,
corsOptions,
imgDir,
port,
- Read upRead up
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 renderTableBody
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderTableBody = (data: ChannelCollab): React.ReactElement[] => {
if (!data.participants) return [<></>]
return data.participants.map((participantCollab, key) => {
const handleSaveRow = (row: RowItem[], pKey = -1): void => {
if (pKey === -1) {
Function renderTableBody
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderTableBody = (data: ChannelChat): React.ReactElement[] => {
if (!data.participants) return [<></>]
return data.participants.map((participantChat, key) => {
const handleSaveRow = (row: RowItem[], pKey = -1): void => {
if (pKey === -1) {
Function renderTableBody
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderTableBody = (data: ChannelCustom): React.ReactElement[] => {
if (!data.participants) return [<></>]
return data.participants.map((participant, key) => {
const handleSaveRow = (row: RowItem[], pKey = -1): void => {
if (pKey === -1) {
Function render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render () {
let modal
switch (this.props.currentModal.modal) {
case 'delete':
modal = <DeleteModal />
Function sendMessage
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const sendMessage = (e: React.MouseEvent<HTMLButtonElement>): void => {
e.persist()
const details: MessageDetails = {
channel: channel.uniqid,
from: {
Function factory
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const factory = (state: PlayerUi): Factory => {
return (node: TabNode): React.ReactNode => {
/** helper to determine if the specified channel should be rendered */
const renderThisChannel = (channelData?: ChannelUI): boolean => {
if (channelData) {
Function saveNewMessage
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const saveNewMessage = (newFeatureCollection: FeatureCollection<Geometry, GeoJsonProperties>) => {
if (newFeatureCollection) {
const timestamp = new Date().toISOString()
const details: MessageDetails = {
channel: channel.uniqid,
Function onDragged
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const onDragged = (id: number | string, latLngs: LatLng | LatLng[] | LatLng[][]) => {
if (featureCollection && featureCollection.features) {
const cloneFeatureCollection = cloneDeep(featureCollection)
const idx = cloneFeatureCollection.features.findIndex(f => f.properties?.id === id)
if (idx !== -1 && latLngs) {
Function checkV3ParticipantStates
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const checkV3ParticipantStates = (channel: ChannelTypes, selectedForce: string | undefined, selectedRole: Role['roleId'], isObserver: boolean): CheckParticipantStates => {
if (selectedForce === undefined) throw new Error('selectedForce is undefined')
const channelParts: CoreParticipant[] = channel.participants
const participatingForce: CoreParticipant | undefined = channelParts && channelParts.find(p => matchedForceFilter(p.forceUniqid, selectedForce))
// not a member of this channel, return false answer
Consider simplifying this complex logical expression. Open
Open
if (row.type === ROW_WITH_COLLAPSIBLE_TYPE) {
const { collapsible, cells, rowKey } = row
const tableCells = cells || row
// ideally we'll use the contents of cell zero (message-id). If we can't
// just use the row count
Function wargameListPromise
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const wargameListPromise = allDbsPromise.then(allDbs => {
const wargameDbs = allDbs.filter(name => name.includes('wargame'))
const reversedWargameDbs = wargameDbs.reverse()
return Promise.all(reversedWargameDbs.map(async db => {
const databaseName = checkSqliteExists(db)
Function Template
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Template: StoryFn = (args) => {
// the channels child element may theoretically be undefined, we
// make the compiler happy
if (args.channels === undefined) {
return <div />