Skip to content
This repository was archived by the owner on Mar 27, 2018. It is now read-only.

I15_1 (9.3pre) Rewrite MockNeXusSlit to return an NXslit rather than …#575

Merged
gerring merged 5 commits intomasterfrom
MockNeXusSlit-rewrite
Feb 28, 2017
Merged

I15_1 (9.3pre) Rewrite MockNeXusSlit to return an NXslit rather than …#575
gerring merged 5 commits intomasterfrom
MockNeXusSlit-rewrite

Conversation

@Mark-Booth
Copy link
Copy Markdown
Member

…NXpositioner

* @param container
* @throws NexusException if the attributes could not be added for any reason
*/
private static void registerAttributes(NXobject nexusObject, IScanAttributeContainer container) throws NexusException {
Copy link
Copy Markdown
Contributor

@gerring gerring Feb 28, 2017

Choose a reason for hiding this comment

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

MAJOR Remove this unused private "registerAttributes" method. rule

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is used in the public getNexusProvider() method!

if (container.getScanAttributeNames()!=null) for(String attrName : container.getScanAttributeNames()) {
try {
nexusObject.setField(attrName, container.getScanAttribute(attrName));
} catch (Exception e) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SonarQube appears to be missing that we now throw without losing the exception, just as in the example.

}
}

private void write(Number demand, Number actual, IPosition loc) throws Exception {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAJOR Remove this unused private "write" method. rule
MAJOR Define and throw a dedicated exception instead of using a generic one. rule

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

write is used in the public setPosition() method!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Suggestions for which exception to throw appreciated...

if (demand!=null) {
int index = loc.getIndex(getName());
if (index<0) {
throw new Exception("Incorrect data index for scan for value of '"+getName()+"'. The index is "+index);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAJOR Define and throw a dedicated exception instead of using a generic one. rule

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Suggestions for which exception to throw appreciated...

@gerring
Copy link
Copy Markdown
Contributor

gerring commented Feb 28, 2017

SonarQube analysis reported 4 issues

  • MAJOR 4 major

Watch the comments in this conversation to review them.

The scannable under test is dcs, which is supposed to be an NXslit, but
this test assumes it will be an NXpositioner.
@gerring gerring merged commit 4322bbd into master Feb 28, 2017
@gerring gerring deleted the MockNeXusSlit-rewrite branch February 28, 2017 16:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants