serge-web/serge-web

View on GitHub

Showing 809 of 809 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

(function (factory, window) {
  'use strict'
  if (typeof define === 'function' && define.amd) {
    define(['leaflet'], factory)
  } else if (typeof exports === 'object') {
Severity: Major
Found in client/static/leaflet/ruler/leaflet.ruler.js and 1 other location - About 2 wks to fix
client/public/leaflet/ruler/leaflet.ruler.js on lines 2..171

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

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

(function (factory, window) {
  'use strict'
  if (typeof define === 'function' && define.amd) {
    define(['leaflet'], factory)
  } else if (typeof exports === 'object') {
Severity: Major
Found in client/public/leaflet/ruler/leaflet.ruler.js and 1 other location - About 2 wks to fix
client/static/leaflet/ruler/leaflet.ruler.js on lines 2..171

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

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

File set_latest_wargame_message_mock.ts has 1785 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { CHANNEL_CHAT, CHANNEL_CUSTOM, CUSTOM_MESSAGE, FEEDBACK_MESSAGE, PARTICIPANT_CHAT, PARTICIPANT_CUSTOM } from 'src/config'
import { PlayerUi } from 'src/custom-types'

const state: PlayerUi = {
  selectedForce: undefined,

    Similar blocks of code found in 2 locations. Consider refactoring.
    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) {
    client/src/Components/local/organisms/setting-channels/channels/chat.tsx on lines 130..169

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

    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

        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) {
    client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 186..225

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

    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

    Function AdminGameSetup has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
    Open

    const AdminGameSetup: React.FC = () => {
      const dispatch = useDispatch()
      const { wargame, messageTypes }: { wargame: WargamesState, messageTypes: MessageTypes } = useSelector(({ wargame, messageTypes }: RootState) => ({ wargame, messageTypes }))
    
      const {
    Severity: Minor
    Found in client/src/Views/GameSetupNew.tsx - About 1 day 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

    File message-templates.mock.ts has 792 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { TemplateBody } from 'src/custom-types'
    
    const messageTemplatesMock: TemplateBody[] = [
      {
        completed: false,
    Severity: Major
    Found in client/src/mocks/message-templates.mock.ts - About 1 day to fix

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

        app.get('/:wargame/turns', (req, res) => {
          const databaseName = checkSqliteExists(req.params.wargame)
      
          if (!databaseName) {
            res.status(404).send({ msg: 'Wrong Wargame Name', data: null })
      Severity: Major
      Found in server/providers/couchdb.js and 1 other location - About 1 day to fix
      server/providers/pouchdb.js on lines 231..265

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

        app.get('/:wargame/turns', (req, res) => {
          const databaseName = checkSqliteExists(req.params.wargame)
      
          if (!databaseName) {
            res.status(404).send({ msg: 'Wrong Wargame Name', data: null })
      Severity: Major
      Found in server/providers/pouchdb.js and 1 other location - About 1 day to fix
      server/providers/couchdb.js on lines 234..268

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              templates: [
                {
                  lastUpdated: '2019-09-30T12:37:26.705Z',
                  title: 'PG19 Weekly Orders',
                  details: {
      client/src/Tests/ActionsAndReducers/playerUI/data/set_latest_wargame_message_mock.ts on lines 247..326

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

            templates: [
              {
                lastUpdated: '2019-09-30T12:37:26.705Z',
                title: 'PG19 Weekly Orders',
                details: {
      client/src/Tests/ActionsAndReducers/playerUI/data/set_latest_wargame_message_mock.ts on lines 966..1045

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

      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

      Function renderContent has 299 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const renderContent = (): React.ReactNode => {
          if (!localChannelUpdates) return null
      
          const handleSaveRows = (participants: ParticipantCollab[]): void => {
            const newChannel = { ...localChannelUpdates }

        Function pouchDb has 281 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const pouchDb = (app, io, pouchOptions) => {
          const PouchDB = require('pouchdb-core')
            .plugin(require('pouchdb-adapter-node-websql'))
            .plugin(require('pouchdb-adapter-http'))
            .plugin(require('pouchdb-mapreduce'))
        Severity: Major
        Found in server/providers/pouchdb.js - About 1 day to fix

          File coa-messages.mock.ts has 627 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { CUSTOM_MESSAGE, CollaborativeMessageStates } from 'src/config'
          import { MessageCustom, Role } from 'src/custom-types'
          import { forces } from './forces.mock'
          
          const whiteGC: Role = forces[0].roles[0]
          Severity: Major
          Found in client/src/mocks/coa-messages.mock.ts - About 1 day to fix

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                'Daily intentions': {
                  lastUpdated: '2019-09-30T12:37:26.705Z',
                  title: 'Daily intentions',
                  details: {
                    type: 'object',
            client/src/Tests/ActionsAndReducers/playerUI/data/set_all_messages_mock.ts on lines 287..355

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

            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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                bb: {
                  lastUpdated: '2019-09-30T12:37:26.705Z',
                  title: 'Daily intentions',
                  details: {
                    type: 'object',
            client/src/Tests/ActionsAndReducers/playerUI/data/set_latest_wargame_message_mock.ts on lines 498..566

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

            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

            Function JsonEditor has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
            Open

            export const JsonEditor: React.FC<Props> = ({
              messageId,
              messageContent,
              title,
              template,
            Severity: Minor
            Found in client/src/Components/local/molecules/json-editor/index.tsx - About 1 day 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 MappingPanel has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
            Open

            export const MappingPanel: React.FC<MappingPanelProps> = ({ onClose, features, rendererProps, selected, onSelect, onSave, forceStyles }): React.ReactElement => {
              const [filterredFeatures, setFilterredFeatures] = useState<FeatureCollection<Geometry, GeoJsonProperties> | undefined>(features)
              const [pendingSaveFeatures, setPendingSaveFeatures] = useState<FeatureCollection<Geometry, GeoJsonProperties> | undefined>(features)
              const [openAddFilter, setOpenAddFilter] = useState<boolean>(false)
              const [propertyFiltersListPanel, setPropertyFiltersListPanel] = useState<string[]>([])
            Severity: Minor
            Found in client/src/Components/local/atoms/mapping-panel/index.tsx - About 1 day 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 couchDb has 270 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const couchDb = (app, io, pouchOptions) => {
              const CouchDB = require('pouchdb-core')
              const PouchDB = require('pouchdb-core')
                .plugin(require('pouchdb-adapter-node-websql'))
                .plugin(require('pouchdb-adapter-http'))
            Severity: Major
            Found in server/providers/couchdb.js - About 1 day to fix

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

                  'Weather forecast': {
                    lastUpdated: '2019-09-30T12:37:26.705Z',
                    title: 'Weather forecast',
                    details: {
                      type: 'object',
              client/src/Tests/ActionsAndReducers/playerUI/data/set_latest_wargame_message_mock.ts on lines 1581..1649
              client/src/mocks/message-templates.mock.ts on lines 651..719

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

              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

              Severity
              Category
              Status
              Source
              Language