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

Preliminary work for JSON import/export (Sourcery refactored) #103

Merged
merged 1 commit into from
Aug 8, 2021

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Aug 8, 2021

Pull Request #102 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the json-import-export branch, then run:

git fetch origin sourcery/json-import-export
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from tpaviot August 8, 2021 06:18
@sourcery-ai sourcery-ai bot force-pushed the sourcery/json-import-export branch from 46d18dc to aa3dac3 Compare August 8, 2021 06:20
if not constraint in self.constraints:
if constraint not in self.constraints:
Copy link
Author

Choose a reason for hiding this comment

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

Function SchedulingContext.add_constraint refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines -73 to +85
problem_properties = {}
problem_properties["name"] = scheduling_problem.name
problem_properties["horizon"] = scheduling_problem.horizon_defined_value
problem_properties["delta_time"] = scheduling_problem.delta_time
problem_properties["start_time"] = scheduling_problem.start_time
problem_properties["end_time"] = scheduling_problem.end_time
problem_properties = {
'name': scheduling_problem.name,
'horizon': scheduling_problem.horizon_defined_value,
'delta_time': scheduling_problem.delta_time,
'start_time': scheduling_problem.start_time,
'end_time': scheduling_problem.end_time,
}

d["ProblemParameters"] = problem_properties
# Tasks
tasks = {}
for task in scheduling_problem.context.tasks:
new_task_entry = {}
new_task_entry["type"] = type(task).__name__
new_task_entry["optional"] = task.optional
new_task_entry = {'type': type(task).__name__, 'optional': task.optional}
Copy link
Author

Choose a reason for hiding this comment

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

Function export_json_to_string refactored with the following changes:

  • Merge dictionary assignment with declaration (merge-dict-assign)
  • Simplify logical expression using De Morgan identities (de-morgan)

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Aug 8, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.02%.

Quality metrics Before After Change
Complexity 1.42 ⭐ 1.42 ⭐ 0.00
Method Length 21.93 ⭐ 21.86 ⭐ -0.07 👍
Working memory 4.56 ⭐ 4.56 ⭐ 0.00
Quality 90.63% 90.65% 0.02% 👍
Other metrics Before After Change
Lines 109 109 0
Changed files Quality Before Quality After Quality Change
processscheduler/context.py 90.63% ⭐ 90.65% ⭐ 0.02% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2021

Codecov Report

Merging #103 (aa3dac3) into json-import-export (33c9615) will increase coverage by 0.00%.
The diff coverage is 85.71%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           json-import-export     #103   +/-   ##
===================================================
  Coverage               95.48%   95.49%           
===================================================
  Files                      38       38           
  Lines                    4009     3993   -16     
===================================================
- Hits                     3828     3813   -15     
+ Misses                    181      180    -1     
Impacted Files Coverage Δ
processscheduler/json_io.py 95.94% <83.33%> (+0.39%) ⬆️
processscheduler/context.py 87.93% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33c9615...aa3dac3. Read the comment docs.

@tpaviot tpaviot merged commit b4e87fa into json-import-export Aug 8, 2021
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

2 participants