200ok-ch/organice

View on GitHub
src/lib/headline_filter.js

Summary

Maintainability
F
6 days
Test Coverage

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

export const computeCompletions = (todoKeywords, tagNames, allProperties) => (
  filterExpr,
  filterString,
  curserPosition
) => {
Severity: Minor
Found in src/lib/headline_filter.js - 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 timeFilter has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

export const timeFilter = (filterDescription) => {
  const timeFilterDescription = filterDescription.field.timerange;
  let lower;
  let upper;
  if (timeFilterDescription.type === 'point') {
Severity: Minor
Found in src/lib/headline_filter.js - 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

Avoid deeply nested control flow statements.
Open

    if (charBeforeCursor === ':') {
      if (charTwoBeforeCursor === ' ' || charTwoBeforeCursor === '') return tagAndPropNames;
      else {
        // Either property name or text filter
        const indexOfOtherColon = filterString.substring(0, curserPosition - 1).lastIndexOf(':');
Severity: Major
Found in src/lib/headline_filter.js - About 45 mins to fix

    Avoid too many return statements within this function.
    Open

          return todoKeywords;
    Severity: Major
    Found in src/lib/headline_filter.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          if (charBeforeCursor === ':') return tagAndPropNames;
      Severity: Major
      Found in src/lib/headline_filter.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return fromUnit(new Date(), from.unit);
        Severity: Major
        Found in src/lib/headline_filter.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return toUnit(new Date(), to.unit);
          Severity: Major
          Found in src/lib/headline_filter.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  if (charTwoBeforeCursor === ' ' || charTwoBeforeCursor === '') return tagAndPropNames;
            Severity: Major
            Found in src/lib/headline_filter.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                return [];
              Severity: Major
              Found in src/lib/headline_filter.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return tagAndPropNames;
                Severity: Major
                Found in src/lib/headline_filter.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return tagNames;
                  Severity: Major
                  Found in src/lib/headline_filter.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              return computeAllPropertyValuesFor(fromJS(allProperties), maybePropertyName)
                                .flatMap(quoteStringIfPossible)
                                .toJS();
                    Severity: Major
                    Found in src/lib/headline_filter.js - About 30 mins to fix

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

                      const endOfDate = (to) => {
                        const temp = new Date();
                        temp.setFullYear(to.year);
                        if (to.month === null) {
                          return endOfYear(temp);
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 5 hrs to fix
                      src/lib/headline_filter.js on lines 24..37

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

                      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 startOfDate = (from) => {
                        const temp = new Date();
                        temp.setFullYear(from.year);
                        if (from.month === null) {
                          return startOfYear(temp);
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 5 hrs to fix
                      src/lib/headline_filter.js on lines 39..52

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

                      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 resolveFrom = (from) => {
                        if (from === null) {
                          return new Date();
                        } else if (from.type === 'timestamp') {
                          return startOfDate(from);
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 5 hrs to fix
                      src/lib/headline_filter.js on lines 122..134

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

                      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 resolveTo = (to) => {
                        if (to === null) {
                          return new Date();
                        } else if (to.type === 'timestamp') {
                          return endOfDate(to);
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 5 hrs to fix
                      src/lib/headline_filter.js on lines 108..120

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

                      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 toUnit = (date, unit) => {
                        const d = new Date(date);
                        switch (unit) {
                          case 'h':
                            return endOfHour(d);
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 2 hrs to fix
                      src/lib/headline_filter.js on lines 72..88

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

                      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 fromUnit = (date, unit) => {
                        const d = new Date(date);
                        switch (unit) {
                          case 'h':
                            return startOfHour(d);
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 2 hrs to fix
                      src/lib/headline_filter.js on lines 90..106

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

                      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 toSpecial = (to) => {
                        const temp = new Date();
                        if (to.value === 'now') {
                          return temp;
                        } else if (to.value === 'today') {
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 1 hr to fix
                      src/lib/headline_filter.js on lines 54..61

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

                      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 fromSpecial = (from) => {
                        const temp = new Date();
                        if (from.value === 'now') {
                          return temp;
                        } else if (from.value === 'today') {
                      Severity: Major
                      Found in src/lib/headline_filter.js and 1 other location - About 1 hr to fix
                      src/lib/headline_filter.js on lines 63..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 64.

                      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 scheduleds = planningItems
                            .filter((p) => p.get('type') === 'SCHEDULED')
                            .map((p) => p.get('timestamp'));
                      Severity: Minor
                      Found in src/lib/headline_filter.js and 1 other location - About 50 mins to fix
                      src/lib/headline_filter.js on lines 241..243

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

                      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 deadlines = planningItems
                            .filter((p) => p.get('type') === 'DEADLINE')
                            .map((p) => p.get('timestamp'));
                      Severity: Minor
                      Found in src/lib/headline_filter.js and 1 other location - About 50 mins to fix
                      src/lib/headline_filter.js on lines 238..240

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

                      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 filterDescCS = filterField
                          .filter((f) => f.field.type === 'description' && f.field.text.type === 'case-sensitive')
                          .map((x) => x.field.text.words);
                      Severity: Minor
                      Found in src/lib/headline_filter.js and 1 other location - About 45 mins to fix
                      src/lib/headline_filter.js on lines 218..220

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

                      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 filterDesc = filterField
                          .filter((f) => f.field.type === 'description' && f.field.text.type === 'ignore-case')
                          .map((x) => x.field.text.words.map((y) => y.toLowerCase()));
                      Severity: Minor
                      Found in src/lib/headline_filter.js and 1 other location - About 45 mins to fix
                      src/lib/headline_filter.js on lines 221..223

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

                      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

                      There are no issues that match your filters.

                      Category
                      Status