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

Sourcery refactored develop branch #3

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Feb 16, 2022

Branch develop refactored by Sourcery.

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

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 develop branch, then run:

git fetch origin sourcery/develop
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from kayhayen February 16, 2022 10:11
nonCommand = getattr(namespace, "non_command", None)
if nonCommand:
if nonCommand := getattr(namespace, "non_command", None):
Copy link
Author

Choose a reason for hiding this comment

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

Function main.RemainderSetAction.__call__ refactored with the following changes:

Comment on lines -118 to +124
if baseDir:
baseDir = os.path.normcase(baseDir)
if baseDir.endswith(os.path.sep):
baseDir = baseDir[0:-1]
return baseDir
else:
if not baseDir:
# Converts empty string to None
return None
baseDir = os.path.normcase(baseDir)
if baseDir.endswith(os.path.sep):
baseDir = baseDir[:-1]
return baseDir
Copy link
Author

Choose a reason for hiding this comment

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

Function normalizeBaseDir refactored with the following changes:

Comment on lines -187 to +186
return os.path.join(self.manifestSectionDir, manifestHash + ".json")
return os.path.join(self.manifestSectionDir, f'{manifestHash}.json')
Copy link
Author

Choose a reason for hiding this comment

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

Function ManifestSection.manifestPath refactored with the following changes:

Comment on lines -301 to +307
["/" + k + collapseBasedirInCmdPath(arg) for arg in arguments[k]]
[
f'/{k}{collapseBasedirInCmdPath(arg)}'
for arg in arguments[k]
]
)

else:
commandLine.extend(["/" + k + arg for arg in arguments[k]])
commandLine.extend([f'/{k}{arg}' for arg in arguments[k]])
Copy link
Author

Choose a reason for hiding this comment

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

Function ManifestRepository.getManifestHash refactored with the following changes:

Comment on lines -335 to +338
self._mutexName = "Local\\" + mutexName
self._mutexName = f'Local\\{mutexName}'
Copy link
Author

Choose a reason for hiding this comment

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

Function CacheLock.__init__ refactored with the following changes:

Comment on lines -1765 to +1768
setOfSources = set(sourceFile for sourceFile, _ in sourceFiles)
setOfSources = {sourceFile for sourceFile, _ in sourceFiles}
Copy link
Author

Choose a reason for hiding this comment

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

Function filterSourceFiles refactored with the following changes:

key_prefix=(getStringHash(self.fileStrategy.dir) + "_").encode("UTF-8"),
key_prefix=f'{getStringHash(self.fileStrategy.dir)}_'.encode("UTF-8"),
Copy link
Author

Choose a reason for hiding this comment

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

Function CacheMemcacheStrategy.connect refactored with the following changes:

remote = self.remoteCache.getEntry(key)
if remote:
if remote := self.remoteCache.getEntry(key):
Copy link
Author

Choose a reason for hiding this comment

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

Function CacheFileWithMemcacheFallbackStrategy.getEntry refactored with the following changes:

Comment on lines -232 to +236
local = self.localCache.getManifest(manifestHash)
if local:
if local := self.localCache.getManifest(manifestHash):
printTraceStatement(
"{} local manifest hit for {}".format(self, manifestHash)
)
return local
remote = self.remoteCache.getManifest(manifestHash)
if remote:
if remote := self.remoteCache.getManifest(manifestHash):
Copy link
Author

Choose a reason for hiding this comment

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

Function CacheFileWithMemcacheFallbackStrategy.getManifest refactored with the following changes:

Comment on lines -159 to +160
out = []
lines = text.splitlines(True)
for line in lines:
out.append(line.replace("\r", "<CR>").replace("\n", "<LN>"))
out = [line.replace("\r", "<CR>").replace("\n", "<LN>") for line in lines]
Copy link
Author

Choose a reason for hiding this comment

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

Function TestCompileRuns.testPipedOutput.debugLinebreaks refactored with the following changes:

Comment on lines -848 to +846
mpFlag = "/MP" + str(len(sources))
mpFlag = f'/MP{len(sources)}'
Copy link
Author

Choose a reason for hiding this comment

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

Function RunParallelBase.testOutput refactored with the following changes:

Comment on lines -48 to +51
cls.sources = []
for i in range(1, TestConcurrency.NUM_SOURCE_FILES+1):
cls.sources.append(os.path.join(ASSETS_DIR, 'concurrency', 'file{:02d}.cpp'.format(i)))
cls.sources = [
os.path.join(ASSETS_DIR, 'concurrency', 'file{:02d}.cpp'.format(i))
for i in range(1, TestConcurrency.NUM_SOURCE_FILES + 1)
]
Copy link
Author

Choose a reason for hiding this comment

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

Function TestConcurrency.setUpClass refactored with the following changes:

Comment on lines -524 to -527
else:
# We just want to know if we got a proper source file.
# Other AnalysisErrors are ignored.
pass
Copy link
Author

Choose a reason for hiding this comment

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

Function TestAnalyzeCommandLine._testSourceFilesOk refactored with the following changes:

This removes the following comments ( why? ):

# Other AnalysisErrors are ignored.
# We just want to know if we got a proper source file.

Comment on lines -1136 to +1132
for i in range(0, 999):
for i in range(999):
Copy link
Author

Choose a reason for hiding this comment

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

Function TestCompression.assertEntrySizeIsCorrect refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Feb 16, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 2.61 ⭐ 2.52 ⭐ -0.09 👍
Method Length 49.37 ⭐ 49.30 ⭐ -0.07 👍
Working memory 6.23 🙂 6.21 🙂 -0.02 👍
Quality 75.85% 75.94% 0.09% 👍
Other metrics Before After Change
Lines 4207 4198 -9
Changed files Quality Before Quality After Quality Change
clcache/main.py 53.13% 🙂 52.92% 🙂 -0.21% 👎
clcache/caching.py 75.21% ⭐ 75.46% ⭐ 0.25% 👍
clcache/storage.py 89.16% ⭐ 88.92% ⭐ -0.24% 👎
tests/test_integration.py 71.58% 🙂 71.68% 🙂 0.10% 👍
tests/test_performance.py 65.72% 🙂 64.44% 🙂 -1.28% 👎
tests/test_unit.py 82.34% ⭐ 82.34% ⭐ 0.00%

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

File Function Complexity Length Working Memory Quality Recommendation
clcache/caching.py processDirect 24 😞 235 ⛔ 16 ⛔ 26.53% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
clcache/caching.py CommandLineAnalyzer.parseArgumentsAndInputFiles 28 😞 180 😞 13 😞 31.97% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tests/test_integration.py TestCompileRuns.testPipedOutput 15 🙂 268 ⛔ 13 😞 35.16% 😞 Try splitting into smaller methods. Extract out complex expressions
clcache/caching.py CommandLineAnalyzer.analyze 19 😞 214.99 ⛔ 11 😞 38.26% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
clcache/main.py main 15 🙂 316 ⛔ 10 😞 38.66% 😞 Try splitting into smaller methods. Extract out complex expressions

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!

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

0 participants