Skip to content

Commit 5b03955

Browse files
author
Shreyas Balakrishna
committed
fixup! fixup! fixup! fixup! fixup! Blah
1 parent 557688b commit 5b03955

15 files changed

+52
-41
lines changed

.rubocop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4-
TargetRubyVersion: 2.5
4+
TargetRubyVersion: 2.7
55
DisabledByDefault: false
66

7-
Metrics/LineLength:
7+
Layout/LineLength:
88
Max: 140

cpp_dependency_graph.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Gem::Specification.new do |s|
2929
s.rubygems_version = '3.1.2'
3030

3131
s.add_runtime_dependency 'docopt', '~> 0.6'
32-
s.add_runtime_dependency 'ruby-graphviz', '~> 1.2'
3332
s.add_runtime_dependency 'json', '~> 2.3.0'
33+
s.add_runtime_dependency 'ruby-graphviz', '~> 1.2'
3434

3535
s.add_development_dependency 'bundler', '~> 2.1'
3636
s.add_development_dependency 'debase', '~> 0.2'

lib/cpp_dependency_graph/bidirectional_hash.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def rfetch(value)
2525

2626
def fetch_from(hash, key)
2727
return nil unless hash.key?(key)
28+
2829
v = hash[key]
2930
v.length == 1 ? v.first : v.dup
3031
end

lib/cpp_dependency_graph/component_dependency_graph.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def all_cyclic_links
2020

2121
def links(name)
2222
return {} unless all_links.key?(name)
23+
2324
links = incoming_links(name)
2425
links.merge!(outgoing_links(name))
2526
links

lib/cpp_dependency_graph/dir_tree.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class DirTree
1111
attr_reader :tree
1212

1313
def initialize(path)
14-
@tree ||= File.directory?(path) ? parse_dirs(path) : {}
14+
@tree = File.directory?(path) ? parse_dirs(path) : {}
1515
end
1616

1717
private
@@ -22,9 +22,12 @@ def parse_dirs(path, name = nil)
2222
# TODO: Use Dir.map.compact|filter instead here
2323
Dir.foreach(path) do |entry|
2424
next if ['..', '.'].include?(entry)
25+
2526
full_path = File.join(path, entry)
2627
next unless File.directory?(full_path)
28+
2729
next unless source_files_present?(full_path)
30+
2831
data[:children] << parse_dirs(full_path, entry)
2932
end
3033
data

lib/cpp_dependency_graph/directory_parser.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
# Utility methods for parsing directories
14
module DirectoryParser
25
def fetch_all_dirs(root_dir)
36
Find.find(root_dir).select { |e| File.directory?(e) && e != root_dir }

lib/cpp_dependency_graph/file_dependency_graph.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def all_cyclic_links
2020

2121
def links(name)
2222
return {} unless all_links.key?(name)
23+
2324
links = incoming_links(name)
2425
links.merge!(outgoing_links(name))
2526
links

lib/cpp_dependency_graph/graph_to_dot_visualiser.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
class GraphToDotVisualiser
77
def generate(deps, file)
88
@g = GraphViz.new('dependency_graph')
9-
nodes = create_nodes(deps)
10-
connect_nodes(deps, nodes)
11-
@g.output(:dot => file)
9+
create_nodes(deps)
10+
connect_nodes(deps)
11+
@g.output(dot: file)
1212
end
1313

1414
private
@@ -17,20 +17,20 @@ def create_nodes(deps)
1717
node_names = deps.flat_map do |_, links|
1818
links.map { |link| [link.source, link.target] }.flatten
1919
end.uniq
20-
nodes = node_names.map { |name| [name, create_node(name)] }.to_h
21-
nodes
20+
node_names.each do |name|
21+
add_node(name)
22+
end
2223
end
2324

24-
def create_node(name)
25-
node = @g.add_node(name, :shape => 'box3d')
26-
node
25+
def add_node(name)
26+
@g.add_node(name, shape: 'box3d')
2727
end
2828

29-
def connect_nodes(deps, nodes)
29+
def connect_nodes(deps)
3030
deps.each do |source, links|
3131
links.each do |link|
3232
if link.cyclic?
33-
@g.add_edges(source, link.target, :color => 'red')
33+
@g.add_edges(source, link.target, color: 'red')
3434
else
3535
@g.add_edges(source, link.target)
3636
end

lib/cpp_dependency_graph/include_component_dependency_graph.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def initialize(project)
1111
end
1212

1313
def all_links
14-
components = @project.source_components
1514
@project.source_files.map do |file|
1615
links = file.includes.map { |inc| Link.new(file.basename, inc, false) }
1716
[file.basename, links]

lib/cpp_dependency_graph/include_to_component_resolver.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def external_includes(component)
1919

2020
def component_for_include(include)
2121
return '' unless source_files.key?(include)
22+
2223
@component_include_map_cache[include] = component_for_include_private(include) unless @component_include_map_cache.key?(include)
2324
@component_include_map_cache[include]
2425
end
@@ -35,6 +36,7 @@ def component_for_include_private(include)
3536
header_file = source_files[include]
3637
implementation_files = implementation_files(header_file)
3738
return header_file.parent_component if implementation_files.empty?
39+
3840
implementation_files[0].parent_component
3941
end
4042

0 commit comments

Comments
 (0)