ActivityWatch/aw-webui

View on GitHub

Showing 43 of 53 total issues

Function load has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async load({ save }: { save?: boolean } = {}) {
      if (typeof localStorage === 'undefined') {
        console.error('localStorage is not supported');
        return;
      }
Severity: Minor
Found in src/stores/settings.ts - About 1 hr to fix

    Function buildBarchartDataset has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function buildBarchartDataset(data_by_hour: HourlyData[], classes: Category[]): Dataset[] {
      const SEP = '>>>';
      const data = data_by_hour;
      if (data) {
        const category_names: Set<string> = new Set(
    Severity: Minor
    Found in src/util/datasets.ts - About 1 hr to fix

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

        export function buildBarchartDataset(data_by_hour: HourlyData[], classes: Category[]): Dataset[] {
          const SEP = '>>>';
          const data = data_by_hour;
          if (data) {
            const category_names: Set<string> = new Set(
        Severity: Minor
        Found in src/util/datasets.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 create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function create(el: HTMLElement) {
          // Clear the svg in case we are redrawing
          rootEl = d3.select(el);
          rootEl.selectAll('svg').remove();
        
        
        Severity: Minor
        Found in src/visualizations/sunburst-clock.ts - About 1 hr to fix

          Function split_by_hour_into_data has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function split_by_hour_into_data(events) {
            if (events === undefined || events === null || events.length == 0) return [];
            const d = moment(events[0].timestamp).startOf('day');
            const hoursOffset = get_hour_offset();
            return _.range(0, 24).map(h => {
          Severity: Minor
          Found in src/util/transforms.ts - About 1 hr to fix

            Function query_active_history has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async query_active_history({ timeperiod, ...query_options }: QueryOptions) {
                  const settingsStore = useSettingsStore();
                  const bucketsStore = useBucketsStore();
                  // Filter out periods that are already in the history, and that are in the future
                  const periods = timeperiodStrsAroundTimeperiod(timeperiod).filter(tp_str => {
            Severity: Minor
            Found in src/stores/activity.ts - About 1 hr to fix

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

                beforeCreate: function () {
                  const that = this;
                  const methods = this.$options.methods || {};
                  for (const key in methods) {
                    const original = methods[key];
              Severity: Minor
              Found in src/mixins/asyncErrorCaptured.js - 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 getTitleAttr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export function getTitleAttr(bucket: IBucket, e: IEvent) {
                if (bucket.type == 'currentwindow') {
                  return e.data.app;
                } else if (bucket.type == 'web.tab.current') {
                  const domainRegex = /^.+:\/\/(?:www.)?([^/]+)/;
              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 updateSummedEvents has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                container: HTMLElement,
                summedEvents: IEvent[],
                titleKeyFunc: (event: IEvent) => string,
                hoverKeyFunc: (event: IEvent) => string,
                colorKeyFunc: (event: IEvent) => string,
              Severity: Minor
              Found in src/visualizations/summary.ts - About 45 mins to fix

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

                  export function buildTooltip(bucket, e) {
                    // WARNING: XSS risk, make sure to sanitize properly
                    // FIXME: Not actually tested against XSS attacks, implementation needs to be verified in tests.
                    let inner = 'Unknown bucket type';
                  
                  
                  Severity: Minor
                  Found in src/util/tooltip.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

                  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

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

                      async save() {
                        // We want to avoid saving to localStorage to not accidentally mess up pre-migration data
                        // For example, if the user is using several browsers, and opened in their non-main browser on first run after upgrade.
                        const saveToLocalStorage = false;
                  
                  
                  Severity: Minor
                  Found in src/stores/settings.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

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

                  export function periodLengthConvertMoment(periodLength: string) {
                    const settingsStore = useSettingsStore();
                    if (periodLength === 'day') {
                      return 'day';
                    } else if (periodLength === 'week') {
                  Severity: Minor
                  Found in src/util/timeperiod.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

                  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

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

                  export function getColorFromCategory(c: Category, allCats: Category[]): string {
                    // Returns the color for a certain category, falling back to parents if none set
                    if (c && c.data && c.data.color) {
                      return c.data.color;
                    } else if (c && c.name.slice(0, -1).length > 0) {
                  Severity: Minor
                  Found in src/util/color.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

                  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 'day';
                    Severity: Major
                    Found in src/util/timeperiod.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return 'YYYY-MM-DD';
                      Severity: Major
                      Found in src/util/timeperiod.ts - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language