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

Circular dependencies #4

Closed
wants to merge 11 commits into from

Conversation

soonernotfaster
Copy link
Contributor

In this branch I have done the following:

  1. Added basic test coverage through the Data class using RSpec
  2. Implemented the feature
  3. Added example file in lib to test behavior.

I am happy to discuss switching to another testing framework if you prefer, I simply chose what I am most comfortable with. Also, I am hoping for a better way to test the app then pollute it with the test classes.
Fixes #3

Steven Solomon added 6 commits August 19, 2017 11:39
- Move definitions and relations parsing into parse method
- Test app from Data class rather than File class
- Add example circular file to test
@@ -0,0 +1,3 @@
class ClassWithOneIncludedMixin
include ModuleWithNoRelations
end

Choose a reason for hiding this comment

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

Final newline missing.

@@ -0,0 +1,3 @@
class ClassWithOneIncludedMixin

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.


# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin

Choose a reason for hiding this comment

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

Do not use block comments.

@@ -0,0 +1,100 @@
# This file was generated by the `rspec --init` command. Conventionally, all

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.

@@ -0,0 +1,2 @@
module ModuleWithNoRelations
end

Choose a reason for hiding this comment

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

Final newline missing.

@@ -0,0 +1,17 @@
class A

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.

@@ -0,0 +1,3 @@
class ClassWithOneExtendedMixin
extend ModuleWithNoRelations
end

Choose a reason for hiding this comment

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

Final newline missing.

@@ -0,0 +1,3 @@
class ClassWithOneExtendedMixin

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.

end
end
end
end

Choose a reason for hiding this comment

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

Final newline missing.


context 'Circular dependency' do
context 'across classes' do
let(:file_path) {'spec/parser/fixtures/classes_circular_dependency.rb'}

Choose a reason for hiding this comment

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

Space missing inside {.
Space missing inside }.

@@ -0,0 +1,5 @@
class ClassWithOneClassDependency

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.

@@ -0,0 +1,2 @@
class ClassWithNoRelations

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.

context 'Class depends on another class' do
let(:file_namespace) {:ClassWithOneClassDependency}
let(:dependency_namespace) {:ClassWithNoRelations}
let(:file_path) { 'spec/parser/fixtures/class_with_one_class_dependency.rb' }

Choose a reason for hiding this comment

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

Line is too long. [81/80]


context 'Class depends on another class' do
let(:file_namespace) {:ClassWithOneClassDependency}
let(:dependency_namespace) {:ClassWithNoRelations}

Choose a reason for hiding this comment

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

Space missing inside {.
Space missing inside }.

end

context 'Class depends on another class' do
let(:file_namespace) {:ClassWithOneClassDependency}

Choose a reason for hiding this comment

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

Space missing inside {.
Space missing inside }.

context 'extended' do
let(:file_namespace) {:ClassWithOneExtendedMixin}
let(:dependency_namespace) {:ModuleWithNoRelations}
let(:file_path) { 'spec/parser/fixtures/class_with_one_extended_mixin.rb' }

Choose a reason for hiding this comment

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

Line is too long. [81/80]


context 'extended' do
let(:file_namespace) {:ClassWithOneExtendedMixin}
let(:dependency_namespace) {:ModuleWithNoRelations}

Choose a reason for hiding this comment

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

Space missing inside {.
Space missing inside }.

@@ -0,0 +1,101 @@
# frozen_string_literal: false
# This file was generated by the `rspec --init` command. Conventionally, all

Choose a reason for hiding this comment

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

Add an empty line after magic comments.

@soonernotfaster
Copy link
Contributor Author

Is there a way to run these checks locally? I don't want to have a million tiny commits.

@emad-elsaid
Copy link
Owner

@steven-solomon Yup, try rubocop locally I think houndci is just running that command

@@ -0,0 +1,116 @@
require 'rubrowser/data'

describe Rubrowser::Data do

Choose a reason for hiding this comment

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

Block has too many lines. [90/25]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we make an exception to this rule for spec files?

Copy link
Owner

Choose a reason for hiding this comment

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

sure

@@ -0,0 +1,116 @@
require 'rubrowser/data'

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.

@@ -4,6 +4,10 @@ d3.json("/data.json", function(error, data) {
$('.toolbox').show();
});

var classForCircular = function(d) {
return d.circular ? 'circular' : ''
}

Choose a reason for hiding this comment

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

Missing semicolon.

@@ -4,6 +4,10 @@ d3.json("/data.json", function(error, data) {
$('.toolbox').show();
});

var classForCircular = function(d) {
return d.circular ? 'circular' : ''

Choose a reason for hiding this comment

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

Missing semicolon.

end

private

class Graph < Hash

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.

end

@relations.each do |relation|
if components.include?(relation.namespace.to_s)

Choose a reason for hiding this comment

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

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, I feel that using &&/|| for control flow would make the code unclear. How do you feel?

def self.do; end
end

class C

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.

def self.do; end
end

class B

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd love to find another way to test the app's circular functionality without including a file that does nothing

@@ -0,0 +1,23 @@
class A

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.
Missing magic comment # frozen_string_literal: true.

Copy link
Contributor Author

@soonernotfaster soonernotfaster left a comment

Choose a reason for hiding this comment

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

Mostly there. I would like to propose an exception to the block rule on test files and comments for classes as no other class in the system has comments like this.

@emad-elsaid
Copy link
Owner

That's a good idea, lets add these exceptions to rubocop config file

@@ -0,0 +1,3 @@
module ModuleWithNoRelations
end

Choose a reason for hiding this comment

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

1 trailing blank lines detected.

class ClassWithOneIncludedMixin
include ModuleWithNoRelations
end

Choose a reason for hiding this comment

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

1 trailing blank lines detected.


def self.do; end
end

Choose a reason for hiding this comment

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

1 trailing blank lines detected.

class ClassWithOneExtendedMixin
extend ModuleWithNoRelations
end

Choose a reason for hiding this comment

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

1 trailing blank lines detected.

ClassWithNoRelations.new
end
end

Choose a reason for hiding this comment

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

1 trailing blank lines detected.

@@ -0,0 +1,6 @@
class ModuleWithOneClassDependency

Choose a reason for hiding this comment

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

Carriage return character detected.
Missing magic comment # frozen_string_literal: true.

ClassWithNoRelations.new
end
end

Choose a reason for hiding this comment

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

1 trailing blank lines detected.

@@ -0,0 +1,3 @@
class ClassWithNoRelations
end

Choose a reason for hiding this comment

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

1 trailing blank lines detected.

@soonernotfaster
Copy link
Contributor Author

Seems like houndci is ignoring the changes to .rubocop.yml. I'm going to close and reopen this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants