ActivityWatch/aw-webui

View on GitHub

Showing 33 of 33 total issues

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

      if (state.editor.available) {
        await dispatch('query_editor', query_options);
      } else {
        console.log('Cannot call query_editor as we do not have any editor buckets');
        await dispatch('query_editor_empty', query_options);
Severity: Minor
Found in src/store/modules/activity.ts and 1 other location - About 45 mins to fix
src/store/modules/activity.ts on lines 178..183

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

      } else if (state.android.available) {
        await dispatch('query_active_history_android', query_options);
      } else {
        console.log('Cannot call query_active_history as we do not have an afk bucket');
        await dispatch('query_active_history_empty', query_options);
Severity: Minor
Found in src/store/modules/activity.ts and 1 other location - About 45 mins to fix
src/store/modules/activity.ts on lines 185..190

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

Function getTitleAttr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function getTitleAttr(bucket: Bucket, e: Event) {
  if (bucket.type == 'currentwindow') {
    return e.data.app;
  } else if (bucket.type == 'web.tab.current') {
    try {
Severity: Minor
Found in src/util/color.ts - About 45 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 update has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function update(container, events, showAFK, chunkfunc, eventfunc) {
Severity: Minor
Found in src/visualizations/timeline.js - About 35 mins to fix

    Function updateSummedEvents has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function updateSummedEvents(container, summedEvents, titleKeyFunc, hoverKeyFunc, colorKeyFunc) {
    Severity: Minor
    Found in src/visualizations/summary.js - About 35 mins to fix

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

          const periods = timeperiodStrsAroundTimeperiod(timeperiod).filter(tp_str => {
            return !_.includes(state.active.history, tp_str);
          });
      Severity: Minor
      Found in src/store/modules/activity.ts and 1 other location - About 35 mins to fix
      src/store/modules/activity.ts on lines 315..317

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

      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

          const periods = timeperiodStrsAroundTimeperiod(timeperiod).filter(tp_str => {
            return !_.includes(state.active.history, tp_str);
          });
      Severity: Minor
      Found in src/store/modules/activity.ts and 1 other location - About 35 mins to fix
      src/store/modules/activity.ts on lines 274..276

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

      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 handleError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function handleError(error, vm, info) {
        let cur = vm;
        while ((cur = cur.$parent)) {
          const hooks = cur.$options.errorCaptured || [];
          for (const hook of hooks) if (hook.call(cur, error, vm, info) === false) break;
      Severity: Minor
      Found in src/mixins/asyncErrorCaptured.js - About 35 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

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

          const data = await this._vm.$aw.query(
            periods,
            queries.dailyActivityQueryAndroid(state.buckets.android[0])
          );
      Severity: Minor
      Found in src/store/modules/activity.ts and 1 other location - About 35 mins to fix
      src/store/modules/activity.ts on lines 277..280

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

      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 data = await this._vm.$aw.query(
            periods,
            queries.dailyActivityQuery(state.buckets.afk[0])
          );
      Severity: Minor
      Found in src/store/modules/activity.ts and 1 other location - About 35 mins to fix
      src/store/modules/activity.ts on lines 318..321

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

      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

      Avoid too many return statements within this function.
      Open

          return e.data.title;
      Severity: Major
      Found in src/util/color.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return e.data.label;
        Severity: Major
        Found in src/util/color.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return _.last(e.data.file.split('/'));
          Severity: Major
          Found in src/util/color.ts - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language