ActivityWatch/aw-webui

View on GitHub
src/stores/buckets.ts

Summary

Maintainability
A
1 hr
Test Coverage

Function bucketsByDevice has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    bucketsByDevice: function () {
      let devices = _.mapValues(
        _.groupBy(this.buckets, b => b.hostname || b.device_id),
        d => {
          const hostnames = _.uniq(_.map(d, b => b.hostname || b.data.hostname));
Severity: Minor
Found in src/stores/buckets.ts - About 1 hr to fix

    Function update_buckets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        update_buckets(this: State, buckets: IBucket[]): void {
          this.buckets = _.orderBy(buckets, [b => b.id], ['asc']).map(b => {
            // Some harmonization as aw-server-rust and aw-server-python APIs diverge slightly
            if (!b.last_updated && b.metadata && b.metadata.end) {
              b.last_updated = b.metadata.end;
    Severity: Minor
    Found in src/stores/buckets.ts - 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

    There are no issues that match your filters.

    Category
    Status