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

Introducing Rubocop #66

Merged
merged 19 commits into from Oct 12, 2016
Merged

Introducing Rubocop #66

merged 19 commits into from Oct 12, 2016

Conversation

abinashmeher999
Copy link
Contributor

No description provided.

Created by executing `rubocop --auto-gen-config`

Currently since the .rubocop.yml file is empty it uses the default.yml settings as the default for the style-guide. Custom rules can be added into the local .rubocop.yml and it will override the default.

`inherit_from: .rubocop_todo.yml` currently ignores the violations reported in .rubocop_todo.yml.

Next step is to remove the exclusions in the todo file and fix the violations. This way all the corrections regarding a particular style can be added in a single commit. Repeat this till all exclusions are fixed.
@abinashmeher999 abinashmeher999 changed the title [WIP] Introducing Rubocop Introducing Rubocop Oct 6, 2016
@abinashmeher999
Copy link
Contributor Author

@v0dro I referred to the discussion here: SciRuby/nmatrix#521 to set this up. Every violation passes for now. Could you please review?

@v0dro
Copy link

v0dro commented Oct 7, 2016

Yeah works. You can add rubocop to the Travis build so that it fails in case of violations and it can be easily seen on GitHub.

This is triggered because method names shouldn't start with an
UpperCase, but this instance is okay as it emulates a class
@isuruf
Copy link
Member

isuruf commented Oct 8, 2016

@abinashmeher999, can you enable edits from maintainers?

@abinashmeher999
Copy link
Contributor Author

Done.

@isuruf isuruf added this to the Release 0.1.0 milestone Oct 8, 2016
@isuruf
Copy link
Member

isuruf commented Oct 8, 2016

This is now ready for review

@certik
Copy link
Contributor

certik commented Oct 11, 2016

@abinashmeher999, @zverok would you mind reviewing this please?

It's +1 from me.

@zverok
Copy link
Collaborator

zverok commented Oct 11, 2016

Looking at it.

Copy link
Collaborator

@zverok zverok left a comment

Choose a reason for hiding this comment

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

Have some minor concerns, but in general it is a hell of a good work 👍

@@ -25,45 +25,53 @@ def symbols ary_or_string, *params

# Make an Array of SymEngine::Symbols from the parameters we received,
# now that they're normalized.
ary_or_string.map do |symbol_or_string|
ary_or_string.map do |symbol_or_string|
SymEngine::Symbol.new(symbol_or_string)
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

ary_or_string.map(&SymEngine::Symbol.method(:new))

subject { SymEngine.evalf(SymEngine.sin(SymEngine(2)), 53, true) }
it { is_expected.to be_a SymEngine::RealDouble }
it { is_expected.to be_within(1e-15).of(0.909297426825682) }
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Blank line here?..

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 see that. There are more such occurrences in this file alone where a blank line will increase the readability. Maybe further beautification(like fixing line length too) can be added with a new PR by limiting this PR to only get rubocop to a passing state.

it { is_expected.to be_a SymEngine::ComplexMPC }
its(:imaginary) { is_expected.to be_within(SymEngine::RealMPFR.new("1e-32", 100)).of(SymEngine::RealMPFR.new("0.84147098480789650665250232163005", 100)) }
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

...and here

else
f.capitalize
end
}
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be honest, for me the rule "do..end for multiline blocks" could be disabled at least for spec/ folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either is okay with me.


it_behaves_like 'two symbols'
end

context 'with a splatted argument' do
let(:args) { %w[x y] } # it would be several separate strings on *args
let(:args) { %w(x y) } # it would be several separate strings on *args
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, matter of personal style, but it is easy to redefine in .rubocop.yml what is appropriate limitation characters for %w arrays. And for me, %w[] is much more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

asinh: 'Math.asinh', acosh: 'Math.acosh', atanh: 'Math.atanh',
pi: 'Math::PI', E: 'Math::E', I: '::Complex::I',
dirichlet_eta: 'SymEngine::Utils::evalf_dirichlet_eta',
zeta: 'SymEngine::Utils::evalf_zeta', gamma: 'Math.gamma' }.map { |from, to| [/(\b#{from}\b)/, to] }.to_h.freeze
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line should be broken down, maybe when we are fixing exceeding line length.

@abinashmeher999
Copy link
Contributor Author

Thanks @isuruf!

@abinashmeher999
Copy link
Contributor Author

Made the suggested changes.

@isuruf isuruf merged commit 7ccfd5d into symengine:master Oct 12, 2016
@isuruf
Copy link
Member

isuruf commented Oct 12, 2016

@abinashmeher999, thanks for the work and @zverok, @v0dro, @certik for the reviews

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.

None yet

5 participants