renzholy/mongood

View on GitHub

Showing 64 of 64 total issues

Function DocumentsList has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

export default function DocumentsList() {
  const displayMode = useAppSelector((state) => state.docs.displayMode)
  const [{ conn, database, collection }] = useRouterQuery()
  const connection = useConnection(conn)
  const index = useAppSelector((state) => state.docs.index)
Severity: Minor
Found in src/components/documents-list.tsx - About 5 hrs 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 stringify has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

export function stringify(
  val: MongoData,
  hasIndent = false,
  depth = 0,
): string {
Severity: Minor
Found in src/utils/ejson.ts - About 4 hrs 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 DatabaseNav has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

export default function DatabaseNav() {
  const theme = getTheme()
  const [{ conn, database, collection }, setRoute] = useRouterQuery()
  const expandedDatabases = useAppSelector(
    (state) => state.root.expandedDatabases,
Severity: Minor
Found in src/components/database-nav.tsx - About 3 hrs 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 ConnectionItem has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

function ConnectionItem(props: { connection: string; disabled?: boolean }) {
  const uri = useMemo(() => {
    try {
      return mongodbUri.parse(props.connection)
    } catch {
Severity: Minor
Found in src/components/connection-edit-modal.tsx - About 3 hrs 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 IndexFeatures has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

export default function IndexFeatures(props: { value: IndexDescription }) {
  const features = useMemo<{ text: string; data: object }[]>(
    () =>
      compact([
        size(props.value.key) > 1 && !('textIndexVersion' in props.value)
Severity: Minor
Found in src/components/pure/index-features.tsx - About 2 hrs 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 generate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function generate(doc: MongoData): Schema {
  if (typeof doc === 'string') {
    return {
      bsonType: ['string'],
    }
Severity: Minor
Found in src/utils/schema.ts - About 2 hrs 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 ProfilingSummary has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export default function ProfilingSummary() {
  const [{ conn }, setRoute] = useRouterQuery()
  const connection = useConnection(conn)
  const { data: databases } = useCommandDatabases()
  const { data: hosts } = useCommandIsMaster()
Severity: Minor
Found in src/components/profiling-summary.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 OperationsList has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export default function OperationsList() {
  const { data, error, mutate } = useCommandCurrentOp()
  const [{ conn, collection }, setRoute] = useRouterQuery()
  const connection = useConnection(conn)
  const [target, setTarget] = useState<MouseEvent>()
Severity: Minor
Found in src/components/operations-list.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 IndexesList has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function IndexesList() {
  const { data } = useCommandIndexStats()
  const { data: collStats, error: collStatsError } = useCommandCollStats()
  const { data: indexes, error: indexesError, mutate } = useCommandListIndexes()
  const [{ conn, database, collection }] = useRouterQuery()
Severity: Minor
Found in src/components/indexes-list.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 ProfilingList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export default function ProfilingList() {
  const { data, error } = useCommandSystemProfileFind()
  const [{ collection }] = useRouterQuery()
  const invokedProfiling = useAppSelector(
    (state) => state.profiling.invokedProfiling,
Severity: Minor
Found in src/components/profiling-list.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 Schema has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export default function Schema() {
  const [{ conn, database, collection }] = useRouterQuery()
  const { data, mutate } = useCommandListCollections()
  const isDarkMode = useDarkMode()
  const [validationAction, setValidationAction] =
Severity: Minor
Found in src/pages/schema.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 parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  parse(uri: string): UriObject {
    const uriObject: UriObject = { hosts: [] }

    let i = uri.indexOf('://')
    if (i < 0) {
Severity: Minor
Found in src/utils/mongo-uri.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 getItem has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function getItem<T>(
  type: StorageType,
  key: string,
): string | number | T | undefined {
  if (typeof window === 'undefined') {
Severity: Minor
Found in src/utils/storage.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 ExecStage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function ExecStage(props: {
  value?: { [key: string]: MongoData }
}) {
  const theme = getTheme()
  const value = useMemo<ExecStats | undefined>(
Severity: Minor
Found in src/components/pure/exec-stage.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 format has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  format(uriObject: UriObject) {
    if (!uriObject) {
      return (this.scheme || 'mongodb') + '://localhost'
    }

Severity: Minor
Found in src/utils/mongo-uri.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

Consider simplifying this complex logical expression.
Open

              if (databaseMatched || collectionMatched) {
                return {
                  key: _database,
                  name: _database,
                  title: _database,
Severity: Major
Found in src/components/database-nav.tsx - About 1 hr to fix

    Function DocumentRowContextualMenu has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function DocumentRowContextualMenu<
      T extends { [key: string]: MongoData },
    >(props: {
      hidden: boolean
      onDismiss(): void
    Severity: Minor
    Found in src/components/document-row-contextual-menu.tsx - About 55 mins 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 EditorModal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function EditorModal<T extends MongoData>(props: {
      title: string
      readOnly?: boolean
      value?: T
      onChange?(value: T): void
    Severity: Minor
    Found in src/components/pure/editor-modal.tsx - About 55 mins 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

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

          <Stack
            horizontal={true}
            tokens={{ childrenGap: 10, padding: 10 }}
            styles={{ root: { height } }}
          >
    Severity: Minor
    Found in src/components/document-filter-stack.tsx and 1 other location - About 40 mins to fix
    src/components/document-filter-stack.tsx on lines 76..209

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

    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

        <Stack
          horizontal={true}
          tokens={{ childrenGap: 10, padding: 10 }}
          styles={{ root: { height } }}
        >
    Severity: Minor
    Found in src/components/document-filter-stack.tsx and 1 other location - About 40 mins to fix
    src/components/document-filter-stack.tsx on lines 44..70

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

    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