Showing 252 of 825 total issues
Function _renderItem
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_renderItem(item, menu) {
const selected = this._isSelected(item)
const p = L.DomUtil.create('div', 'leaflet-control-select-menu-line', menu)
const pContent = L.DomUtil.create(
Function onMessageValuesChanged
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const onMessageValuesChanged = (messageLocal: MessagesValues, value: string[], action: Action, type: string): MessagesValues => {
const nextMessageLocal: MessagesValues = { ...messageLocal }
switch (type) {
case MessageGroupType.MESSAGE_TEMPLATE:
Function componentFor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const componentFor = (
key: string,
prop: SelectedProps,
propertyType: PropertyType,
value: any,
Function onDelete
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const onDelete = () => {
const curTab = wargame.currentTab
switch (type) {
case 'force': {
Function createWargame
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const createWargame = async (dispatch: Dispatch, wargameLists : WargameList[]): Promise<Wargame> => {
const name = `wargame-${uniqid.time()}`
const db = new DbProvider(databasePath + name)
addWargameDbStore({ name, db })
Function handleSaveForce
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleSaveForce = (newForces: ForceData[]) => {
const { selectedForce } = forces
const { uniqid } = selectedForce as ForceData
const newForceData = newForces.find(force => force.uniqid === uniqid)
if (newForceData) {
Function postNewMessageTypeToDb
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const postNewMessageTypeToDb = (schema) => {
return new Promise((resolve, reject) => {
(async () => {
// Get all existing message types from the database
const allMessages = await getAllMessagesFromDb()
Function addMessage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const addMessage = (messageDetail, schema) => {
return new Promise((resolve, reject) => {
(async () => {
const allMessages = await getAllMessagesFromDb()
const matchedName = allMessages.find((el) => el.details.title === messageDetail.title && el._id !== messageDetail.id)
Function renderChatOptions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderChatOptions = (): React.ReactElement => {
const handleCheckbox = (event: ChangeEvent<HTMLInputElement>): void => {
const newChannel = { ...localChannelUpdates }
newChannel.hideMessageAuthor = event.target.checked
setChatAuthorHidden(event.target.checked)
Function getParticipantStates
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const getParticipantStates = (
channel: ChannelTypes, forceId: string | undefined,
role: Role['roleId'], isObserver: boolean,
allTemplatesByKey: TemplateBodysByKey,
// TODO: move it to reducer, for future default Message can be changed from admin
Function configCommonProps
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const configCommonProps = (propIn: Record<string, unknown>, gameDate: string): Record<string, unknown> => {
const prop = deepCopy(propIn)
switch (prop.format) {
case 'datetime-local':
// no, don't overwride flatpick
Function Template
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Template: StoryFn<StoryPropTypes> = (args) => {
const { privateMessage, confirmCancel } = args
const channel = watuWargame.data.channels.channels[0]
const channels = {}
watuWargame.data.channels.channels.forEach(c => {
Consider simplifying this complex logical expression. Open
if ((isUmpire && isObserver) || isParticipant) {
const { forceIcons, forceColors, forceNames } = buildForceIconsColorsNames(channel.participants, allForces)
const isCollab = channel.channelType === CHANNEL_COLLAB
const messages = messagesFiltered.filter(
(message) => (message.details && message.details.channel === channel.uniqid) || (!isCollab && message.messageType === INFO_MESSAGE_CLIPPED)
Function getFormatAndDefaultFieldName
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const getFormatAndDefaultFieldName = (schema: { format: string }, value: string): FormatInfo => {
switch (schema.format) {
case 'datetime-local':
// don't bother with validation if it's na IZO string
if (isISOString(value)) {
- 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 openMessage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const openMessage = (channel: string, payloadMessage: MessageChannel, newState: PlayerUi): ChannelUI => {
// mutating `messages` array - copyState at top of switch
const channelMessages: Array<MessageChannel> = (newState.channels[channel].messages || [])
const selectedForce = newState.selectedForce ? newState.selectedForce.uniqid : ''
if (payloadMessage._id !== undefined) {
- 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 SplitButton
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const SplitButton: React.FC<Props> = ({ label, options = [], onClick }: Props) => {
const gridStyles = useButtonStyle()
const [open, setOpen] = useState<boolean>(false)
const anchorRef = useRef<any>(null)
const [selectedIndex, setSelectedIndex] = useState<number>(-1)
- 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 componentFor
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const componentFor = (
key: string,
prop: SelectedProps,
propertyType: PropertyType,
value: any,
- 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 CollabStatusBoard
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const CollabStatusBoard: React.FC<CollabStatusBoardProps> = ({
templates, messages, channelColb, isObserver, isUmpire, onChange, role, forces,
gameDate, onMessageRead, onMarkAllAsRead, onMarkAllAsUnRead, currentWargame, collabActivity
}) => {
const [showArchived, setShowArchived] = useState<boolean>(false)
- 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 findEmptyRolenames
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const findEmptyRolenames = (newData: ForceData, forces: ForceData[]): Array<{ forceName:string, roleName: string }> => {
// use new force-data object, to check new values
const forcesData = _.map(forces, force => force.uniqid === newData.uniqid ? newData : force)
// create flat list of data objects to check
- 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 SchemaEditor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function SchemaEditor (elementId) {
Editor.call(this, elementId)
// Check whether the node is a properties button for an object,
// and not for the schema of an object named properties
- 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"