Showing 178 of 178 total issues
Method tryToReadMetadata
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function tryToReadMetadata()
{
$serialized_metadata = fgets($this->file_pointer);
if (!$serialized_metadata) {
return new BulkStreamError(
Method generate
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function generate(ConnectorMap $connector_map)
{
$details = [];
$failing = 0;
$working = 0;
Method guardCommandPreConditions
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function guardCommandPreConditions(AggregateRootCommandInterface $command)
{
if ($this->getHistory()->isEmpty()) {
throw new HistoryEmptyError(
sprintf(
Function applyValues
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function applyValues(EmbeddedEntityEventInterface $event)
{
if (!is_callable([$event, 'getData'])) {
throw new RuntimeError('Event instance is not support due to lack of a getData method.');
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validateValues
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function validateValues(array $values)
{
$errors = [];
$sanitized_values = [];
Method updateAffectedRelatives
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function updateAffectedRelatives(
ProjectionMap $affected_relatives_map,
ProjectionInterface $source_projection
) {
$referenced_identifier = $source_projection->getIdentifier();
Method applyEmbeddedEntityEvent
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function applyEmbeddedEntityEvent(
EmbeddedEntityEventInterface $embedded_entity_event,
$auto_commit = true
) {
$attribute_name = $embedded_entity_event->getParentAttributeName();
Method moveTempFileToFinalLocation
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function moveTempFileToFinalLocation($location, EntityTypeInterface $art)
{
$from_uri = $this->filesystem_service->createTempUri($location, $art); // from temporary storage
$to_uri = $this->filesystem_service->createUri($location, $art); // to final storage
Method processEmbeddedEntityCommand
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processEmbeddedEntityCommand(CommandInterface $command, array $custom_event_state = [])
{
$event_class = $command->getEventClass();
$attribute_name = $command->getParentAttributeName();
Method applyValues
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function applyValues(EmbeddedEntityEventInterface $event)
{
if (!is_callable([$event, 'getData'])) {
throw new RuntimeError('Event instance is not support due to lack of a getData method.');
}
Method executeHandlers
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function executeHandlers($channel_name, EventInterface $event, $subscription_index)
{
if (!$this->channel_map->hasKey($channel_name)) {
throw new RuntimeError(
sprintf(
Method createInitialData
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function createInitialData(
CreateAggregateRootCommand $create_command,
StateMachineInterface $state_machine
) {
$type = $this->getType();
Method read
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function read($identifier, SettingsInterface $settings = null)
{
try {
$view_params = [
'startkey' => sprintf(self::STARTKEY_FILTER, $identifier),
Method mirrorReferencedProjection
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function mirrorReferencedProjection(EntityReferenceInterface $projection)
{
$projection_type = $projection->getType();
$mirrored_attribute_map = $projection_type->getAttributes()->filter(
function (AttributeInterface $attribute) {
Method translateFilters
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function translateFilters(CriteriaList $filter_criteria_list)
{
$elasticsearch_filters = [];
foreach ($filter_criteria_list as $criteria) {
if ($criteria instanceof CriteriaContainerInterface) {
Method proceedWorkflow
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function proceedWorkflow(ProceedWorkflowCommand $workflow_command, StateMachineInterface $state_machine)
{
$this->guardCommandPreConditions($workflow_command);
if ($workflow_command->getCurrentStateName() !== $this->getWorkflowState()) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($this->databaseExists($migration_target)) {
$client = $this->getConnection($migration_target);
$database_name = $this->getDatabaseName($migration_target);
$response = $client->delete('/' . $database_name);
if ($response->getStatusCode() !== 200) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 107.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
$client = $this->getConnection($migration_target);
$database_name = $this->getDatabaseName($migration_target);
$response = $client->put('/' . $database_name);
if ($response->getStatusCode() !== 201) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 107.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method getStatus
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getStatus()
{
if ($this->config->has('fake_status')) {
return new Status($this, $this->config->get('fake_status'));
}
Method loadMigrations
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadMigrations()
{
$migration_dir = $this->config->get('directory');
if (!is_dir($migration_dir) || !is_readable($migration_dir)) {
throw new RuntimeError(sprintf('Given migration path is not a readable directory: %s', $migration_dir));