Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(*): add focus option #295

Merged
merged 8 commits into from
May 9, 2020
Merged

feature(*): add focus option #295

merged 8 commits into from
May 9, 2020

Conversation

sverweij
Copy link
Owner

@sverweij sverweij commented May 1, 2020

Description

  • Adds an option to 'focus' on a bunch of modules, so the output contains:
  1. the modules matching the regular expression in the focus option
  2. the modules that are direct dependencies of 1.
  3. the modules that directly depend on 1.

When you use this option, in the internal data structure each module grows a matchesFocus attribute that has the value true for modules in 1. , false for all modules. This can be helpful for e.g. use in graphical output (see the screenshots below for an example).

  • This PR also makes the processing of filter options more uniform:
    • all filter options can be specified either as a string (focus: "^src/main") or as an object (focus: {path: "^src/main"})
    • internally filter options are represented as the object variant.

This makes sure processing for all filters is uniform, and can be extended easily (while remaining backwards compatible).

Motivation and Context

How Has This Been Tested?

  • Additional automated tests
  • Green CI

Sample and screenshots

Example usage:

depcruise src --focus "^src/main" -v .depcruise-options.js -T dot | dot -T svg > focused-graph.svg
with this `.depcruise-options.js`

This demonstrates the use of the matchesFocus attribute to tweak the dot report. This colors the modules that directly match the 'focus' pattern green, and the rest lighgray:

module.exports = {
  options: {
    includeOnly: "^src",
    reporterOptions: {
      dot: {
        collapsePattern: "node_modules/[^/]+",
        theme: {
          graph: {
            // "ortho" makes graphviz use orthogonal routing. When slow use "true" in stead.
            splines: "ortho",
          },
          modules: [
            {
              criteria: { matchesFocus: true },
              attributes: { fillcolor: "#ccffcc" },
            },
            {
              criteria: { matchesFocus: false },
              attributes: { fillcolor: "#dddddd" },
            },
          ],
        },
      },
    },
  },
};

Which will yield:

image

For reference you can compare this with the complete internal dependency-graph, which you can find here

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 7574 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8429 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8432 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8430 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8446 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8634 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8634 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8811 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 8820 lines exceeds the maximum allowed for the inline comments feature.

@sverweij sverweij force-pushed the feature/focus branch 2 times, most recently from b4a82e5 to 7e7c695 Compare May 7, 2020 17:56
Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 11169 lines exceeds the maximum allowed for the inline comments feature.

sverweij added 7 commits May 7, 2020 20:17
…ther filter options (exclude, doNotFollow

which will help with future expansions, and makes code more maintainable because processing is more symmetrical
Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 9463 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 10002 lines exceeds the maximum allowed for the inline comments feature.

@codeclimate
Copy link

codeclimate bot commented May 9, 2020

Code Climate has analyzed commit 7af2aa1 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (99% is the threshold).

This pull request will bring the total coverage in the repository to 99.9% (0.0% change).

View more on Code Climate.

@sverweij sverweij merged commit 2689a53 into develop May 9, 2020
@sverweij sverweij deleted the feature/focus branch May 9, 2020 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: released
Development

Successfully merging this pull request may close these issues.

Feature request: Is it possible to show up- and downstream nodes of a file or directory?
1 participant