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

CodeQL fixups #2134

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Rdmp.Core/Curation/Data/JoinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ public JoinInfo(ICatalogueRepository repository, ColumnInfo foreignKey, ColumnIn
ExtractionJoinType type, string collation)
{
if (foreignKey.ID == primaryKey.ID)
throw new ArgumentException("Joink Key 1 and Join Key 2 cannot be the same");
throw new ArgumentException("Join Key 1 and Join Key 2 cannot be the same");

if (foreignKey.TableInfo_ID == primaryKey.TableInfo_ID)
throw new ArgumentException("Joink Key 1 and Join Key 2 are from the same table, this is not cool");
throw new ArgumentException("Join Key 1 and Join Key 2 must be from different tables");

repository.InsertAndHydrate(this, new Dictionary<string, object>
{
Expand Down
2 changes: 2 additions & 0 deletions Rdmp.Core/Curation/Data/TableInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,6 @@
DatabaseType == discoveredTable.Database.Server.DatabaseType &&
(!alsoCheckServer ||
discoveredTable.Database.Server.Name.Equals(Server, StringComparison.CurrentCultureIgnoreCase));

public new bool Equals(object o) => base.Equals(o);
}
3 changes: 1 addition & 2 deletions Rdmp.Core/QueryBuilding/Parameters/ParameterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ public ISqlParameter GetOverrideIfAnyFor(ISqlParameter existing)
public void RemoveParameter(ISqlParameter deletable)
{
foreach (var parameters in ParametersFoundSoFarInQueryGeneration.Values)
if (parameters.Contains(deletable))
parameters.Remove(deletable);
parameters.Remove(deletable);
}

/// <summary>
Expand Down
21 changes: 11 additions & 10 deletions Rdmp.UI/Logging/LoggingTabUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ namespace Rdmp.UI.Logging;
/// </summary>
public class LoggingTabUI : LoggingTab_Design
{
private ToolStripTextBox tbContentFilter = new();
private ToolStripLabel label1 = new("Filter:");
private ToolStripLabel label2 = new("Top:");
private ToolStripTextBox tbTop = new() { Text = "10000" };
private ToolStripButton cbPreferNewer = new("Newest") { CheckOnClick = true, Checked = true };
private readonly ToolStripTextBox tbContentFilter = new();
private readonly ToolStripLabel label1 = new("Filter:");
private readonly ToolStripLabel label2 = new("Top:");
private readonly ToolStripTextBox tbTop = new() { Text = "10000" };
private readonly ToolStripButton cbPreferNewer = new("Newest") { CheckOnClick = true, Checked = true };

private Label lblCurrentFilter;
private PictureBox pbRemoveFilter;
Expand Down Expand Up @@ -170,9 +170,10 @@ private IEnumerable<BasicCommandExecution> GetCommands(int rowIdnex)
private static void AddFreeTextSearchColumn(DataTable dt)
{
var dcRowString = dt.Columns.Add("_RowString", typeof(string));
var sb = new StringBuilder();
foreach (DataRow dataRow in dt.Rows)
{
var sb = new StringBuilder();
sb.Clear();
for (var i = 0; i < dt.Columns.Count - 1; i++)
{
sb.Append(dataRow[i]);
Expand Down Expand Up @@ -217,7 +218,7 @@ private void InitializeComponent()
//
// pbRemoveFilter
//
pbRemoveFilter.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Right);
pbRemoveFilter.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pbRemoveFilter.BackColor = Color.Goldenrod;
pbRemoveFilter.Image = (Image)resources.GetObject("pbRemoveFilter.Image");
pbRemoveFilter.Location = new Point(820, 3);
Expand All @@ -230,8 +231,8 @@ private void InitializeComponent()
//
// lblCurrentFilter
//
lblCurrentFilter.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Left
| AnchorStyles.Right);
lblCurrentFilter.Anchor = AnchorStyles.Top | AnchorStyles.Left
| AnchorStyles.Right;
lblCurrentFilter.BackColor = Color.Goldenrod;
lblCurrentFilter.ForeColor = SystemColors.ControlLightLight;
lblCurrentFilter.Location = new Point(3, 3);
Expand Down Expand Up @@ -307,7 +308,7 @@ public void SetFilter(LogViewerFilter filter)
//push the old filter
_navigationTrack?.Append(Filter);
if (_back != null)
_back.Enabled = _navigationTrack.CanBack();
_back.Enabled = _navigationTrack?.CanBack() == true;

if (filter.IsEmpty)
{
Expand Down
18 changes: 7 additions & 11 deletions Rdmp.UI/PipelineUIs/Pipelines/ConfigurePipelineUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class ConfigurePipelineUI : Form
private readonly IPipeline _pipeline;
private readonly IPipelineUseCase _useCase;

private PipelineWorkAreaUI _workArea;
private readonly PipelineWorkAreaUI _workArea;

public ConfigurePipelineUI(IActivateItems activator, IPipeline pipeline, IPipelineUseCase useCase,
ICatalogueRepository repository)
Expand All @@ -46,13 +46,10 @@ public ConfigurePipelineUI(IActivateItems activator, IPipeline pipeline, IPipeli

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.W))
{
Close();
return true;
}
if (keyData != (Keys.Control | Keys.W)) return base.ProcessCmdKey(ref msg, keyData);

return base.ProcessCmdKey(ref msg, keyData);
Close();
return true;
}


Expand All @@ -67,10 +64,9 @@ private void tbName_TextChanged(object sender, EventArgs e)
if (string.IsNullOrWhiteSpace(tbName.Text))
tbName.Text = "NoName";

if (tbName.Text.StartsWith("TO DO:") || tbName.Text.Equals("NoName"))
tbName.ForeColor = Color.Red;
else
tbName.ForeColor = Color.Black;
tbName.ForeColor = tbName.Text.StartsWith("TO DO:", StringComparison.Ordinal) || tbName.Text.Equals("NoName")
? Color.Red
: Color.Black;

try
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 28 additions & 28 deletions Rdmp.UI/PipelineUIs/Pipelines/PipelineDiagramUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Rdmp.UI.PipelineUIs.Pipelines;
/// you are selecting an IPipeline you will see the diagram rendered readonly. If you are editing (See PipelineWorkAreaUI and ConfigurePipelineUI) then you will be able to select
/// and drag and drop in new components to make an IPipeline configuration. On such a dialog you can also select a component to change the components arguments (See ArgumentCollection).
/// </summary>
public partial class PipelineDiagramUI : UserControl
public sealed partial class PipelineDiagramUI : UserControl
{
private IPipeline _pipeline;

Expand All @@ -41,15 +41,15 @@ public partial class PipelineDiagramUI : UserControl
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool AllowReOrdering { get; set; }

private RAGSmiley pipelineSmiley = new();
private readonly RAGSmiley pipelineSmiley = new();

public IPipelineComponent SelectedComponent;
public event PipelineComponentSelectedHandler SelectedComponentChanged;

private IPipelineUseCase _useCase;
private DataFlowPipelineEngineFactory _pipelineFactory;

private ToolStripMenuItem _deleteSelectedMenuItem;
private readonly ToolStripMenuItem _deleteSelectedMenuItem;
private readonly IActivateItems _activator;

public PipelineDiagramUI(IActivateItems activator)
Expand Down Expand Up @@ -77,30 +77,29 @@ public PipelineDiagramUI(IActivateItems activator)

private void DeleteSelectedComponent(object sender, EventArgs e)
{
if (SelectedComponent != null)
if (MessageBox.Show($"Do you want to delete {SelectedComponent.Class}?", "Confirm Delete",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
//if they are deleting the destination
if (SelectedComponent.ID == _pipeline.DestinationPipelineComponent_ID)
{
_pipeline.DestinationPipelineComponent_ID = null;
_pipeline.SaveToDatabase();
}
if (SelectedComponent == null || MessageBox.Show($"Do you want to delete {SelectedComponent.Class}?",
"Confirm Delete",
MessageBoxButtons.YesNo) != DialogResult.Yes) return;

//if they are deleting the source
if (SelectedComponent.ID == _pipeline.SourcePipelineComponent_ID)
{
_pipeline.SourcePipelineComponent_ID = null;
_pipeline.SaveToDatabase();
}
//if they are deleting the destination
if (SelectedComponent.ID == _pipeline.DestinationPipelineComponent_ID)
{
_pipeline.DestinationPipelineComponent_ID = null;
_pipeline.SaveToDatabase();
}

SelectedComponent.DeleteInDatabase();
RefreshUIFromDatabase();
//if they are deleting the source
if (SelectedComponent.ID == _pipeline.SourcePipelineComponent_ID)
{
_pipeline.SourcePipelineComponent_ID = null;
_pipeline.SaveToDatabase();
}

SelectedComponent = null;
_deleteSelectedMenuItem.Enabled = false;
}
SelectedComponent.DeleteInDatabase();
RefreshUIFromDatabase();

SelectedComponent = null;
_deleteSelectedMenuItem.Enabled = false;
}


Expand Down Expand Up @@ -343,10 +342,11 @@ private DragDropEffects component_shouldAllowDrop(DragEventArgs arg, DataFlowCom
var obj = GetAdvertisedObjectFromDragOperation(arg);

//if they are dragging a new component
if (obj != null)
//of the correct role and the source/destination is empty
if (sender.Value == null && obj.GetRole() == sender.GetRole())
return DragDropEffects.Move;
if (obj == null) return DragDropEffects.None;

//of the correct role and the source/destination is empty
if (sender.Value == null && obj.GetRole() == sender.GetRole())
return DragDropEffects.Move;

return DragDropEffects.None;
}
Expand Down
19 changes: 10 additions & 9 deletions Rdmp.UI/ProjectUI/Datasets/ConfigureDatasetUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,12 @@ private void SetupUserInterface()
foreach (var ec in allExtractableColumns)
{
if (ec.CatalogueExtractionInformation_ID == null) continue;

var eiDict = Activator.CoreChildProvider.AllExtractionInformationsDictionary;
var ciDict = Activator.CoreChildProvider.AllCatalogueItemsDictionary;

if (!eiDict.TryGetValue(ec.CatalogueExtractionInformation_ID.Value, out var ei)) continue;

ec.InjectKnown(ei);
ec.InjectKnown(ei.ColumnInfo);

Expand Down Expand Up @@ -754,11 +756,11 @@ private void tbSearch_TextChanged(object sender, EventArgs e)
ObjectListView tree;
var senderTb = (TextBox)sender;

if (sender == tbSearchAvailable)
if (ReferenceEquals(sender, tbSearchAvailable))
tree = olvAvailable;
else if (sender == tbSearchSelected)
else if (ReferenceEquals(sender, tbSearchSelected))
tree = olvSelected;
else if (sender == tbSearchTables)
else if (ReferenceEquals(sender, tbSearchTables))
tree = olvJoin;
else
throw new Exception($"Unexpected sender {sender}");
Expand All @@ -782,12 +784,11 @@ public void RefreshBus_RefreshObject(object sender, RefreshObjectEventArgs e)
//if an ExtractionInformation is being refreshed
if (e.Object is ExtractionInformation ei)
//We should clear any old cached values for this ExtractionInformation amongst selected column
foreach (var c in olvSelected.Objects.OfType<ExtractableColumn>().ToArray())
if (c.CatalogueExtractionInformation_ID == ei.ID)
{
c.InjectKnown(ei);
olvSelected.RefreshObject(c);
}
foreach (var c in olvSelected.Objects.OfType<ExtractableColumn>().Where(c => c.CatalogueExtractionInformation_ID == ei.ID).ToArray())
{
c.InjectKnown(ei);
olvSelected.RefreshObject(c);
}

UpdateJoins();
}
Expand Down
Loading